Skip to content

Commit 674bad4

Browse files
committed
Clarify the use of sessionTransacted
This commit clarifies the role of the external transactionManager for a DMLC and the relationship with the sessionTransacted flag Issue: SPR-9200
1 parent aaae10c commit 674bad4

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

spring-jms/src/main/java/org/springframework/jms/listener/AbstractMessageListenerContainer.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,13 @@
104104
* runtime processing overhead.
105105
* </ul>
106106
*
107-
* <p>Note that it is also possible to specify a
108-
* {@link org.springframework.jms.connection.JmsTransactionManager} as external
109-
* "transactionManager", providing fully synchronized Spring transactions based
110-
* on local JMS transactions. The effect is similar to "sessionTransacted" set
111-
* to "true", the difference being that this external transaction management
112-
* will also affect independent JMS access code within the service layer
113-
* (e.g. based on {@link org.springframework.jms.core.JmsTemplate} or
114-
* {@link org.springframework.jms.connection.TransactionAwareConnectionFactoryProxy}),
115-
* not just direct JMS Session usage in a {@link SessionAwareMessageListener}.
107+
* <p>Note that even if
108+
* {@link org.springframework.jms.connection.JmsTransactionManager} used to
109+
* only provide fully synchronized Spring transactions based
110+
* on local JMS transactions, "sessionTransacted" offers now the same feature and
111+
* is the recommended option when transactions are not managed externally. In
112+
* other words, set the transaction manager only if you are using JTA , or
113+
* synchronizing transactions.
116114
*
117115
* @author Juergen Hoeller
118116
* @author Stephane Nicoll

spring-jms/src/main/java/org/springframework/jms/listener/AbstractPollingMessageListenerContainer.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,13 @@ protected boolean isPubSubNoLocal() {
132132
* Simply switch the {@link #setSessionTransacted "sessionTransacted"} flag
133133
* to "true" in order to use a locally transacted JMS Session for the entire
134134
* receive processing, including any Session operations performed by a
135-
* {@link SessionAwareMessageListener} (e.g. sending a response message).
136-
* Alternatively, a {@link org.springframework.jms.connection.JmsTransactionManager}
137-
* may be used for fully synchronized Spring transactions based on local JMS
138-
* transactions. Check {@link AbstractMessageListenerContainer}'s javadoc for
135+
* {@link SessionAwareMessageListener} (e.g. sending a response message). This
136+
* allows for fully synchronized Spring transactions based on local JMS
137+
* transactions, similar to what
138+
* {@link org.springframework.jms.connection.JmsTransactionManager} provides. Check
139+
* {@link AbstractMessageListenerContainer}'s javadoc for
139140
* a discussion of transaction choices and message redelivery scenarios.
141+
* @see #setSessionTransacted(boolean)
140142
* @see org.springframework.transaction.jta.JtaTransactionManager
141143
* @see org.springframework.jms.connection.JmsTransactionManager
142144
*/

spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,13 @@ public void setCacheLevelName(String constantName) throws IllegalArgumentExcepti
262262
* <p>Default is {@link #CACHE_NONE} if an external transaction manager has been specified
263263
* (to reobtain all resources freshly within the scope of the external transaction),
264264
* and {@link #CACHE_CONSUMER} otherwise (operating with local JMS resources).
265-
* <p>Some J2EE servers only register their JMS resources with an ongoing XA
265+
* <p>Some JavaEE servers only register their JMS resources with an ongoing XA
266266
* transaction in case of a freshly obtained JMS {@code Connection} and {@code Session},
267267
* which is why this listener container by default does not cache any of those.
268-
* However, if you want to optimize for a specific server, consider switching
269-
* this setting to at least {@link #CACHE_CONNECTION} or {@link #CACHE_SESSION}
270-
* even in conjunction with an external transaction manager.
268+
* However, depending on how smart your JavaEE server is with respect to the caching
269+
* of transactional resource, consider switching this setting to at least
270+
* {@link #CACHE_CONNECTION} or {@link #CACHE_SESSION} even in conjunction with an
271+
* external transaction manager.
271272
* @see #CACHE_NONE
272273
* @see #CACHE_CONNECTION
273274
* @see #CACHE_SESSION

spring-jms/src/main/java/org/springframework/jms/support/JmsAccessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public ConnectionFactory getConnectionFactory() {
8686
* <p>Setting this flag to "true" will use a short local JMS transaction
8787
* when running outside of a managed transaction, and a synchronized local
8888
* JMS transaction in case of a managed transaction (other than an XA
89-
* transaction) being present. The latter has the effect of a local JMS
89+
* transaction) being present. This has the effect of a local JMS
9090
* transaction being managed alongside the main transaction (which might
9191
* be a native JDBC transaction), with the JMS transaction committing
9292
* right after the main transaction.

0 commit comments

Comments
 (0)