Closing Session when using Spring's CachingConnectionFactory

后端 未结 2 1398
礼貌的吻别
礼貌的吻别 2021-01-02 12:20

The java doc here related to Spring CachingConnectionFactory has comment :

NOTE: This ConnectionFactory requires explicit closing of all Sessions obta

相关标签:
2条回答
  • 2021-01-02 12:42

    It is generally not a good idea to use a caching connection factory with a listener container, especially when using maxConcurrentConsumers > concurrentConsumers - you can end up with cached consumers in the cache, which get messages where there is no listener, and such messages can get "stuck".

    So, don't use a CCF in this case, it's really intended for use on the producer side.

    Since the container manages concurrency, the sessions/consumers are long-lived and don't need to be cached.

    0 讨论(0)
  • 2021-01-02 12:48

    Application is not required to close the Session when using DefaultMessageListenerContainer, it creates the required sessions and closes them during shutdown.

    Per my understanding the note you mentioned applies when Session is created by application using CachingConnectionFactory reference about which spring will have no clue.

    0 讨论(0)
提交回复
热议问题