-
1. Using Infinispan with transaction manager on standalone code
manik Jan 18, 2011 10:13 AM (in response to sudheerk84)1 of 1 people found this helpfulWhy not just use Hibernate and Infinispan as a second level cache for Hibernate? It will make your life much easier.
-
2. Using Infinispan with transaction manager on standalone code
sudheerk84 Jan 18, 2011 10:49 AM (in response to manik)We wanted much more control over the JDBC statements we issue and wanted a light weight jdbc framework. So we have gone ahead and already started implementing our code with spring JDBC.
Now we are looking for a solution wherein we can commit into teh database and cache in a single transaction ? Is this possible with any transaction manager provided by jboss/spring ?
-
3. Using Infinispan with transaction manager on standalone code
manik Jan 18, 2011 11:19 AM (in response to sudheerk84)Yes it is possible, it will just mean a fair amount of integration code by yourself. You'd need to check the cache, if the entry exists use it, else run your DB query and store the result back in the cache using putForExternalRead()
You would also need to handle value updates by updating the cache.
Is this a single-server or clustered environment?
-
4. Using Infinispan with transaction manager on standalone code
sudheerk84 Jan 18, 2011 11:26 AM (in response to manik)Its a clustered environment. Ans we are looking for a distributed cache.
-
5. Using Infinispan with transaction manager on standalone code
sudheerk84 Jan 18, 2011 11:38 AM (in response to sudheerk84)Thanks a lot for such quick response
If I get ur response right,
First of my usecases can be achived by writing some custom code from my side, which gives me flexibility of fetching from database and then updating the cache.Subsequent reads will take from cache.
My second usecase when i do a write into database and cache I need a transactional behaviour. Is this also possible?
Is so which is the transaction manager i can use for mainting transactions across my database(spring jdbc) and infinispan ?
-
6. Using Infinispan with transaction manager on standalone code
mircea.markus Jan 18, 2011 11:52 AM (in response to sudheerk84)My second usecase when i do a write into database and cache I need a transactional behaviour. Is this also possible?
I guess this means you either write in both or in non. Yes, possible - you'll just have to make sure that Infinispan "sees" the used transaction manager. This is configured through transactionManagerLookupClass attribute of the "transaction" config element.
-
7. Using Infinispan with transaction manager on standalone code
manik Jan 18, 2011 11:57 AM (in response to sudheerk84)Any JTA compliant transaction manager can be used. See the Infinispan docs on JTA integration. JBossTM is a good choice.
-
8. Using Infinispan with transaction manager on standalone code
sudheerk84 Jan 18, 2011 12:00 PM (in response to manik)Thanks a lot for all the replies. I will have a look at JBossTM and publish my finding once i get transaction working across spring jdbc and infinispan.
-
9. Using Infinispan with transaction manager on standalone code
sudheerk84 Jan 19, 2011 10:51 AM (in response to sudheerk84)I started using atomikos transaction manager. I am able to get transaction with teh datasource but when trying to test the behaviour across infinispan i get a exception.
java.lang.ClassCastException: com.atomikos.icatch.jta.UserTransactionManager cannot be cast to org.infinispan.transaction.lookup.TransactionManagerLookup
at org.infinispan.factories.TransactionManagerFactory.construct(TransactionManagerFactory.java:48)
at org.infinispan.factories.AbstractComponentRegistry.getOrCreateComponent(AbstractComponentRegistry.java:315)
at org.infinispan.factories.AbstractComponentRegistry.invokeInjectionMethod(AbstractComponentRegistry.java:251)
at org.infinispan.factories.AbstractComponentRegistry$Component.injectDependencies(AbstractComponentRegistry.java:840)
This is what i have in teh default section of my cache config file.
<default>
<jmxStatistics enabled="true"/>
<clustering mode="replication">
<stateRetrieval
timeout="20000"
fetchInMemoryState="false"
alwaysProvideInMemoryState="false"
/>
<sync replTimeout="20000"/>
</clustering>
<transaction
transactionManagerLookupClass="com.atomikos.icatch.jta.UserTransactionManager"
syncRollbackPhase="false"
syncCommitPhase="false"
useEagerLocking="false"/>
</default>
-
10. Using Infinispan with transaction manager on standalone code
sudheerk84 Jan 19, 2011 11:44 AM (in response to sudheerk84)i just decompiled teh source to check the code
if (this.configuration.getTransactionManagerLookupClass() != null) {
lookup = (TransactionManagerLookup)Util.getInstance(this.configuration.getTransactionManagerLookupClass());
}
}
I get a feel that there is a casting done to org.infinispan.transaction.lookup.TransactionManagerLookup. Isnt this a bug ?
Since it says "Any JTA compliant transaction manager can be used." How can we expect a JTA compaint transaction manager to implement infinispan specific interface ?
-
11. Using Infinispan with transaction manager on standalone code
mircea.markus Jan 19, 2011 11:45 AM (in response to sudheerk84)transactionManagerLookupClass attribute is wrong. It should not tell what TM you are using, but rather how too look it up. I suggest taking a look at the DummyTransactionManagerLookup implementation.
-
12. Using Infinispan with transaction manager on standalone code
sudheerk84 Jan 19, 2011 12:26 PM (in response to mircea.markus)Thanks , my mistake . I totally misunderstood the attribute property.
I have now writen my own look up class which gets teh spring container instantiated transaction manager(atomikos) and it works fine.
Thanks again for such quick reply.