Do not use CachingConnectionFactory on a MessageListenerContainer

Note from java doc for CachingConnectionFactory:

NOTE: This ConnectionFactory requires explicit closing of all Sessions obtained from its shared Connection. This is the usual recommendation for native JMS access code anyway. However, with this ConnectionFactory, its use is mandatory in order to actually allow for Session reuse.

Note also that MessageConsumers obtained from a cached Session won't get closed until the Session will eventually be removed from the pool. This may lead to semantic side effects in some cases.

 

 It is not recommended to use CachingConnectionFactory on a MessageListenerContainer - you can end up with cached consumers in the cache, which get messages where there is no listener, and such messages can get "stuck". The CachingConnectionFactory is really designed to use on the producer other than the listener. Since the container manages concurrency, the sessions/consumers are long-lived and don't need to be cached.

 

你可能感兴趣的:(MessageListener)