You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a simple program using two JMS connections. I'm running it inside Spring Boot, but some of the autowiring is a little bit more explicit to deal with the multiple ConnectionFactories.
UserTransaction utx = com.arjuna.ats.jta.UserTransaction.userTransaction();
XAConnectionFactory xacf2 = context.getBean("qm2", XAConnectionFactory.class);
XAConnectionFactory xacf3 = context.getBean("qm3", XAConnectionFactory.class);
ConnectionFactoryProxy cfp2 = new ConnectionFactoryProxy((XAConnectionFactory) xacf2, new TransactionHelperImpl(tm));
ConnectionFactoryProxy cfp3 = new ConnectionFactoryProxy((XAConnectionFactory) xacf3, new TransactionHelperImpl(tm);
// Should be able to set these up before doing any transactional work.
ctx2 = cfp2.createContext();
ctx3 = cfp3.createContext();
consumer = ctx2.createConsumer(q);
producer = ctx3.createProducer();
for (int i=0;i<2;i++) {
utx.begin();
... do some work
if (i==0) // Alternate between commit/rollback outcomes
utx.commit();
else
utx.rollback():
}
But it does not seem to work - the consumer/producer's operations are not all done inside a coordinated syncpoint. Variations on the code also failed in different ways (such as the two contexts running with independent, non-coordinated transactions.)
The only way I could get this to work was to move the creation of the contexts and the corresponding consumer/producer BELOW the utx.begin() line. So there's a new set of contexts created for each loop or transaction - the TM does not appear to reuse an existing JMSContext. This is very inefficient as creation of a JMSContext can be expensive.
The equivalent program using Atomikos as the TM does appear to work as expected.
Any thoughts?
The text was updated successfully, but these errors were encountered:
ConnectionFactoryProxy isn't pooled, that's why creation of multiple JMSContexts is expected. Do use the pooled variant using messaginghub dependency instead.
This is a simple program using two JMS connections. I'm running it inside Spring Boot, but some of the autowiring is a little bit more explicit to deal with the multiple ConnectionFactories.
But it does not seem to work - the consumer/producer's operations are not all done inside a coordinated syncpoint. Variations on the code also failed in different ways (such as the two contexts running with independent, non-coordinated transactions.)
The only way I could get this to work was to move the creation of the contexts and the corresponding consumer/producer BELOW the
utx.begin()
line. So there's a new set of contexts created for each loop or transaction - the TM does not appear to reuse an existing JMSContext. This is very inefficient as creation of a JMSContext can be expensive.The equivalent program using Atomikos as the TM does appear to work as expected.
Any thoughts?
The text was updated successfully, but these errors were encountered: