Skip to content

Commit 9d4abb6

Browse files
committed
Clarify JMS sessionTransacted flag for local versus global transaction
Closes gh-35897
1 parent a9a4042 commit 9d4abb6

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,18 @@ protected final ConnectionFactory obtainConnectionFactory() {
100100
/**
101101
* Set the transaction mode that is used when creating a JMS {@link Session}.
102102
* Default is "false".
103-
* <p>Note that within a JTA transaction, the parameters passed to
104-
* {@code create(Queue/Topic)Session(boolean transacted, int acknowledgeMode)}
105-
* method are not taken into account. Depending on the Jakarta EE transaction context,
106-
* the container makes its own decisions on these values. Analogously, these
107-
* parameters are not taken into account within a locally managed transaction
108-
* either, since the accessor operates on an existing JMS Session in this case.
109103
* <p>Setting this flag to "true" will use a short local JMS transaction
110104
* when running outside a managed transaction, and a synchronized local
111105
* JMS transaction in case of a managed transaction (other than an XA
112106
* transaction) being present. This has the effect of a local JMS
113107
* transaction being managed alongside the main transaction (which might
114108
* be a native JDBC transaction), with the JMS transaction committing
115109
* right after the main transaction.
110+
* <p>Note that this flag is meant to remain at its default value "false" for
111+
* participating in a global JTA/XA transaction in a Jakarta EE environment.
112+
* While the server may leniently ignore local Session-level transaction
113+
* management in such a scenario, it may also throw unexpected exceptions
114+
* on commit/rollback in case of this Session-level flag being set to "true".
116115
* @see jakarta.jms.Connection#createSession(boolean, int)
117116
*/
118117
public void setSessionTransacted(boolean sessionTransacted) {

0 commit comments

Comments
 (0)