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.
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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With