Skip to content

Commit 61f89a1

Browse files
committed
Refine note on listener container setup with CachingConnectionFactory
Closes gh-25503
1 parent 3e3f051 commit 61f89a1

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,14 @@
9898
* number of 1 consumer, otherwise you'd receive the same message multiple times on
9999
* the same node.
100100
*
101-
* <p><b>Note: Don't use Spring's {@link org.springframework.jms.connection.CachingConnectionFactory}
102-
* in combination with dynamic scaling.</b> Ideally, don't use it with a message
103-
* listener container at all, since it is generally preferable to let the
104-
* listener container itself handle appropriate caching within its lifecycle.
105-
* Also, stopping and restarting a listener container will only work with an
106-
* independent, locally cached Connection - not with an externally cached one.
101+
* <p><b>Note: You may use {@link org.springframework.jms.connection.CachingConnectionFactory}
102+
* with a listener container but it comes with limitations.</b> It is generally preferable
103+
* to let the listener container itself handle appropriate caching within its lifecycle.
104+
* Also, stopping and restarting a listener container will only work with an independent,
105+
* locally cached {@code Connection}, not with an externally cached one. Last but not least,
106+
* with {@code CachingConnectionFactory}, dynamic scaling with custom provider hints such as
107+
* {@link #setMaxMessagesPerTask "maxMessagesPerTask"} can result in JMS messages delivered
108+
* to cached consumers even when they are no longer attached to the listener container.
107109
*
108110
* <p><b>It is strongly recommended to either set {@link #setSessionTransacted
109111
* "sessionTransacted"} to "true" or specify an external {@link #setTransactionManager

0 commit comments

Comments
 (0)