Reputation: 3154
When using the spring-jms, there are 2 options given by spring for connection and session caching for performance gain.
CachingConnectionFactory
and cache the sessions, optionally you can cache producer and consumers as well.DefaultMessageListenerContainer
you can set the cacheLevel to [1:connection caching, 2:session caching], with 3 you can cache consumers as well.My questions Is , why did spring created the redundant functionality ? which one is optimal and fast in terms of performance?
Upvotes: 2
Views: 2253
Reputation: 174494
The caching factory is designed for short-lived sessions such as operations performed with a JmsTemplate
.
It's generally not needed with the listener container (because its sessions are generally long-lived), unless you perform JmsTemplate
operations on the container's thread - to participate in the container's transaction.
In that case, consumers should not be cached by the factory, especially if variable concurrency is in use. See the container javadocs.
Upvotes: 4