Difference between sessionTransacted and JmsTransactionManager
Asked Answered
B

2

6

What is the main difference between using sessionTransacted=true (in JmsTemplate and/or DefaultMessageListenerContainer) and using JmsTransactionManager? Is using sessionTransacted=true enough for both JmsTemplate and DefaultMessageListenerContainer usages? (I don't need XA)

The doc said (in setSessionTransacted method in JmsAccessor), and it seems that shouldn't be a problem:

Setting this flag to "true" will use a short local JMS transaction when running outside of a managed transaction, and a synchronized local JMS transaction in case of a managed transaction (other than an XA transaction) being present.

Bacon answered 23/5, 2014 at 18:47 Comment(0)
R
4

Correct.

On the DefaultMessageListenerContainer(DMLC) you typically only need acknowledgemode=transacted; you would only use a transaction manager on a DMLC if you need to synchronize the JMS transaction with, say, a JDBC transaction or you need to use a platform (JTA) transaction manager.

Further, any downstream JmsTemplate operation on the container's thread will be done in the same session and participate in the transaction.

Similarly, for JmsTemplate operations on a thread that is not a container thread you generally don't need a transaction manager, unless the platform requires it.

Respondent answered 23/5, 2014 at 19:45 Comment(2)
Thanks Gary. By using JmsTransactionManager can we be sure that all jms-transactions will be committed after jbdc-transactions?Bacon
When synchronizing JMS and JDBC transactions, you would add the JDBC transaction manager (not a JMS tx manager) to the listener container; the transaction manager will then synchronize the transactions by committing the DB tx immediately before the JMS tx. It is possible that the JMS commit might fail, so you need to deal with duplicate message deliveries.Respondent
G
2

session transactioned means transaction start when session start, transaction end when session end.if you need more control on the transaction you need JmsTransactionManager (local)

Grory answered 29/5, 2015 at 2:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.