Sharing a TCP/IP connection in IBM MQ classes for JMS

Multiple instances of an MQI channel can be made to share a single TCP/IP connection.

Applications that are running inside the same Java runtime environment, and that use the IBM® MQ classes for JMS or the IBM MQ resource adapter to connect to a queue manager by using the CLIENT transport, can be made to share the same channel instance.

There is a one-to-one relationship between channel instances and TCP/IP connections. One TCP/IP connection is created for every channel instance.

If a channel is defined with the SHARECNV parameter set to a value greater than 1, then that number of conversations can share a channel instance. To enable a connection factory or an activation specification to use this function, set the SHARECONVALLOWED property to YES.

Every JMS connection and JMS session that is created by a JMS application creates its own conversation with the queue manager.

When an activation specification starts up, the IBM MQ resource adapter starts a conversation with the queue manager for the activation specification to use. Every server session in the server session pool that is associated with the activation specification also starts a conversation with the queue manager.

The SHARECNV attribute is a best effort approach to connection sharing. Therefore, when a SHARECNV value greater than 0 is used with the IBM MQ classes for JMS, it is not guaranteed that a new connection request will always share an already established connection.

Calculating the number of channel instances

Use the following formulae to determine the maximum number of channel instances that are created by an application:

Activation specifications

Number of channel instances = (< maxPoolDepth > + 1) / < SHARECNV >

Where < maxPoolDepth > is the value of the maxPoolDepth property and < SHARECNV > is the value of SHARECNV property on the channel that is used by the activation specification.

Other JMS applications

Number of channel instances = (<JMS connections> + <JMS sessions>) / < SHARECNV >

Where <JMS connections> is the number of connections that are created by the application, where <JMS sessions> is the number of JMS sessions that are created by the application, and < SHARECNV > is the value of SHARECNV property on the channel that is used by the activation specification.

Examples

The following examples show how to use the formulae to calculate the number of channel instances that are created on a queue manager by applications by using either the IBM MQ classes for JMS or the IBM MQ resource adapter.

JMS application example
A JMS application connection connects to a queue manager by using the CLIENT transport, and creates a JMS connection and three JMS sessions. The channel that the application is using to connect to the queue manager has the SHARECNV property set to the value of 10. When the application is running, there are four conversations between the application and the queue manager and one channel instance. The four conversations all share the channel instance.
Activation specification example
An activation specification connects to a queue manager by using the CLIENT transport. The activation specification is configured with the maxPoolDepth property set to 10. The channel that the activation specification is configured to use has the SHARECNV property set to 10. When the activation specification is running, and processing 10 messages concurrently, the number of conversations between the activation specification and the queue manager is 11 (10 conversations for the server sessions, and one for the activation specification). The number of channel instances that are used by the activation specification is 2.
Activation specification example
An activation specification connects to a queue manager by using the CLIENT transport. The activation specification is configured with the maxPoolDepth property set to 5. The channel that the activation specification is configured to use has the SHARECNV property set to 0. When the activation specification is running, and processing 5 messages concurrently, the number of conversations between the activation specification and the queue manager is 6 (five conversations for the server sessions, and one for the activation specification). The number of channel instances that are used by the activation specification is 6, because the SHARECNV property on the channel is set to 0, every conversation uses its own channel instance.