News and Events

News and Events

Limit WMQ connections in MuleESB

Recently found an interesting WMQ performance tip when using within MuleSoft’s MuleESB. Original post is on LinkedIn.

First you need to specify explicitly the connection pool as bean in this way:

<spring:bean id=”mqConnectionFactory” name=”wmqConnectionFactory” class=””>
<spring:property name=”transportType” value=”1″/>
<spring:property name=”queueManager” value=”${broker.wmq.manager}”/>
<spring:property name=”hostName” value=”${broker.wmq.hostname}”/>
<spring:property name=”port” value=”${broker.wmq.port}”/>
<spring:property name=”channel” value=”${}”/>

And than create a <jms:caching-connection-factory> element that reference the connection pool in this way.

<jms:caching-connection-factory name=”mqCachingConnectionFactory” connectionFactory-ref=”mqConnectionFactory” sessionCacheSize=”2″ username=”${broker.wmq.user}” password=”${broker.wmq.password}”/>

At the end reference from the wmq connector the cachedConnection pool in this way

<wmq:connector name=”WMQ_Config” validateConnections=”true” doc:name=”WMQ” connectionFactory-ref=”mqCachingConnectionFactory” numberOfConsumers=”1″>

The properties to play with are the sessionCacheSize on the jms:caching-connection-factory and the numberOfConsumers on the WMQ element.

For example if numberOfConsumers = 1 and sessionCacheSize = 2 Mule will open only 2 connections to the broker indipendendly form the number of threads running.