I'm trying to use Spring JMS messaging with @JmsListener in a scalable way, but I'm not seeing it happening. I have a ConnectionFactory bean that returns a factory that connects to an Oracle Advanced Queue through JMS and a database DataSource pool.
The problem starts as every @JmsListener receiver connects again to JMS (and hence to the database pool). My understand is that I can have many @JmsListener methods, one for each service, but in this way it's doing I'm very limited.
The shared connection is turned on, but since each @JmsListener creates a different DefaultMessageListenerContainer, each one have a database connection.
If I also want the services to handle messages concurrently and set container.setConcurrency("3-5")
, then it opens 3 * numberOfListeners
connections.
If I use container.setCacheLevel(DefaultMessageListenerContainer.CACHE_NONE)
then from each second every listener container connects and disconnects from the JMS/database.
I want something that connects one time (or more, if there is concurrent jobs to process) to JMS/database, not to connect count-of-listener times nor to connect-disconnect at each second for every listener.