-
1. 3856639
belaban Nov 22, 2004 2:18 PM (in response to lehren)Couple suggestions:
1. Like Norbert mentioned, use tx now. There is a known problem in locking when tx is not used. We are fixing that in release 1.2.
2. If you are using TreeCacheAop, I'd suggest you try the latest pre-1.2 release in jboss-head. I have done some refactoring and bug fixing on the aop part.
3. If you still are seeing the problem, the best way to help me out to troubleshoot is to write a JUnit test case. That can cut down the time that I need to generate one by myself. Besides, I can check in your test case in the src tree as well. :-)
Thanks,
-Ben -
2. Re: multiple treecaches - TransactionManagers
belaban Nov 22, 2004 4:20 PM (in response to lehren)getInstance() doesn't fail, it just throws a NamingException. That's fine you can simply ignore it.
So you can do this programmatically:
TreeCache c;
DummyTxMgr mgr=DummyTxManager.getInstance();
c.setTransactionManager(mgr);
or via XML
Bela -
3. Re: multiple treecaches - TransactionManagers
lehren Nov 22, 2004 5:57 PM (in response to lehren)Hmmm.. fair enough. Thank you, though I'm having trouble connecting the TreeCache to the TransactionManager. I'm quite sure it's my fault for not understanding it well enough.
There doesn't appear to be a TreeCache.setTransactionManager(..) method as implied by your snippet. Distilling from many examples of how to use the factory I get the following (code abbreviated for legibility):String FACTORY = "org.jboss.cache.transaction.DummyContextFactory"; Properties properties = new Properties(); properties.put(Context.INITIAL_CONTEXT_FACTORY, FACTORY); DummyTransactionManager transactionManager = DummyTransactionManager.getInstance(); org.jboss.cache.TreeCache tc = new org.jboss.cache.TreeCache(); PropertyConfigurator config = new PropertyConfigurator(); config.configure(tc, "Private-TreeCache.xml"); tc.start();
And the Lookup class is in the xml:<attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute>
Then during use most examples call for the something akin to the following, but the lookup always gives me a null.UserTransaction tx = (UserTransaction) new InitialContext(properties).lookup("UserTransaction"); //UserTransaction tx = new DummyUserTransaction(transactionManager); tx.begin(); tc.put(node, key, value); tx.commit();
Your pseudo-code snippet implies that there is an easier way for the default case?
Thank you very much.. -
4. Re: multiple treecaches - TransactionManagers
lehren Nov 22, 2004 6:04 PM (in response to lehren)On a side note, I do seem to get the safe behavior I want with a SERIALIZABLE IsolationLevel and access code like (other code from above is unchanged):
//UserTransaction tx = (UserTransaction) new InitialContext(properties).lookup("UserTransaction"); //UserTransaction tx = new DummyUserTransaction(transactionManager); //tx.begin(); TreeCacheProvider.tc.put(node, key, value); //tx.commit();
Though I would assume that's just because of the SERIALIZABLE spec. -
5. Re: multiple treecaches - TransactionManagers
norbert Nov 23, 2004 3:36 AM (in response to lehren)There's an Interface TransactionManagerLookup that you may implement. Your TransactionManagerLookup-class simply returns the TransactionManager of your choice.
Than you let TreeCache use this transactionmanagerlookup-class to make use of the assigned transactionmanager by either passing an instance to TreeCache via setTransactionManagerLookup(TransactionManagerLookup transactionmanagerlookupinstance), or you specify the className via setTransactionManagerLookupClass(String classname)
You may want to look into the sources of org.jboss.cache.DummyTransactionManagerLookup to have a working example.