Description
Christopher Shannon opened SPR-11958 and commented
It might be nice to have a mode/flag on the CachingConnectionFactory to turn off caching of shared consumers (durable or non-durable) if desired.
The original issue doesn't apply (shown below) since the JMS spec allow allows one thread per session concurrently. This means caching won't be a problem unless someone is trying to share a session across threads and shouldn't be. However, there could be use cases to allow more fine grained control in the CachingConnectionFactory so the user can specify what is and isn't cached. Consumers, shared consumes, durables, no durables, etc could potentially be configured separately so that some types are cached and some not cached.
My team will be testing this out extensively and see what kind of use cases we come up with.
-The issue is that the JMS 2.0 spec supports multiple shared consumers on a subscription, unlike JMS 1.1 which only supports one consumer. I can see two use cases:-
-Caching of shared consumers is a good idea if the intention is to stand up multiple JVMs or multiple connections configured with a shared consumer. In this case caching of the consumers should act just like the caching of non shared consumers (which is currently the case) since there should only be one shared consumer for the same destination per connection.-
-However, if the intent is to allow multiple consumers in the same JVM and same connection, then caching of shared consumers would not work as intended. In this use case, it would actually be useful to not cache the shared consumers. The idea here would be to allow multiple threads to have their own shared consumer to make processing multi-threaded. The reason to add this behavior to the CachingConnectionFactory itself is to allow the benefits of caching of other producers/consumers to be re-used with the same factory.-
-I'm not sure if this is something that should be implemented but it is a thought I had. For now, if separate shared consumers are needed a second SingleConnectionFactory can be used that doesn't cache instead.-
Affects: 4.0.5
Issue Links:
- CachingConnectionFactory doesn't properly cache all consumers with JMS 2.0 [SPR-11956] #16572 CachingConnectionFactory doesn't properly cache all consumers with JMS 2.0
- Support JMS 2.0's shared consumers in message listener containers [SPR-11969] #16585 Support JMS 2.0's shared consumers in message listener containers