padminis
padminis

Reputation: 13

Spring JMS CachingConnectionFactory with cachedProducers enabled

I am currently working on a project to set up spring cachedConnectionFactory sessionCahceSize, please provide answers as to why a sessionCacheSize of 1 (for 3 destinations) registers 1+ (around 3) JMS cached message producers per destination?

The application is running in transacted mode with concurrent thread size as 1

Should I have to look into the strategy of identifying the idle cached producers and evicting the cached producers for optimization?

Upvotes: 1

Views: 2199

Answers (1)

Gary Russell
Gary Russell

Reputation: 174494

You don't show the thread names in your trace, which makes it harder to debug. However...

The producer/consumer cache is at the Session level. If you are sending messages on multiple threads you can end up with a cached producer for each cached session.

  • Thread 1 checks out a session does a send (caching a new producer); checks the session back in.
  • Thread 2 checks out the same session; does a send (using the cached producer).
  • Thread 1 checks out a different session (because the first one is in use); does a send (caching a new producer for that dest/session).
  • Thread 2 checks in the session

sessionCacheSize of 3 (for 3 destinations)

It doesn't work that way; sessions are not tied to destinations; they are general sessions that will cache a producer for each destination it is used for.

Upvotes: 1

Related Questions