Without a caching or pooling connection factory, Spring JMS will create a new connection and session to the destination for every message sent. This is fine if you send a message once every 10 minutes, but is not satisfactory for a high message volume application. So using a caching/pooling connection factory is very common.
Generally, however, the pooling connection factory would only handle the one connection for the Spring JMS message producer. Hence, the default session size is one. I would normally expect to see something like:
<bean class="com.ibm.mq.jms.MQConnectionFactory" id="dest.mqConnectionFactory">
<property name="connectionNameList" value="10.0.0.171(1414)"/>
<property name="queueManager" value="WARP.QMGR"/>
<property name="channel" value="SYSTEM.DEF.SVRCONN"/>
<property name="transportType" value="1"/>
<property name="clientReconnectOptions" value="67108864"/>
</bean>
<bean class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter" id="dest.mqUserCred">
<property name="targetConnectionFactory" ref="dest.mqConnectionFactory"/>
<property name="username" value="XXXX"/>
<property name="password" value="XXXX"/>
</bean>
<bean class="org.apache.activemq.jms.pool.PooledConnectionFactory" destroy-method="stop" id="dest.pooledConnectionFactory" init-method="start">
<property name="idleTimeout" value="${idleTimeout}"/>
<property name="connectionFactory" ref="dest.mqUserCred"/>
</bean>
<bean class="org.apache.camel.component.jms.JmsComponent" id="dest">
<property name="configuration">
<bean class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory" ref="dest.pooledConnectionFactory"/>
</bean>
</property>
</bean>
In the example above, the PooledConnectionFactory
would have one connection and that one JMS connection would have one JMS session. Note that the CachingConnectionFactory
extends the SingleConnectionFactory
. So you have a single JMS connection that can have multiple JMS sessions. You can't share that single JMS connection across threads.
Any JMS message producer will first ask for a JMS connection, and then request a JMS session from the connection. I'm not understanding how you can be sending 50 messages on those 50 JMS sessions with a single JMS connection. If you are trying to share the one CachingConnectionFactory
across multiple message producers, then only one message producer can be active at a time, and it will only use one session.
In my example, I would see a TCP/IP connection from my computer to 10.0.0.171(1414). That JMS connection would have one session. I don't know of any way to have the single JMS connection shared across 50 messages producers on 50 JMS sessions. Obviously, you could write you own code that would do that, but that is not how Spring JMS works.