GlassFish – Configuring JMS Connection Factory to connect to MQ Cluster

Recently, I was trying to find out how to configure a JMS Connection Factory to connect to MQ Cluster. I wanted to send and receive messages from MQ Cluster. It was very hard to find this information in one place. I found that this information is scattered and buried with other info. This blog is to help others to make this information easily available.

I assume that you will be already knowing how to configure a JMS Connection Factory from admin console. So in this blog I will directly get to the point where you will change an  existing JMS Connection Factory to connect to MQ cluster.

In Glassfish, for every JMS Connection Factory we create, the application server automatically creates a Connector Resource. It also creates a Connector Connection Pool with the same name and associates the connector resource with this connection pool. The connector connection pool is by default for the resource adapter called “jmsra”. For connecting to MQ Cluster we are going to create a new connector connection pool for resource adapter, “sun-jms-adapter” and associate this connection pool to the connector resource.

Create a new Connector Connection Pool

In admin console, go to Resources –> Connectors –> Connector Connection Pools. Click on New.

Please make sure that you  select “sun-jms-adapter” as Resource Adapter. Click Next.

Scroll down to the properties section. Add the properties as below:

set the ConnectionURL property with comma separated URLs of MQ brokers. For example: mq://system1:7676,mq://system1:7677

Click on Finish.

Now you can associate this connector connection pool to the connector resource.

Locate the connector resource for the corresponding JMS Connection Factory.

Go to Resources –> Connectors –> Connector Resources –> Select the connector resource with the same name as JMS Connection Factory. On the right hand frame choose the connector pool which you created now. Click on Save

Go Resources –> JMS Resources –> Connection Factories and select your connection factory. You can see the properties you added to the connector connection pool are also available here.

Now you can use this connection factory to send and receive message to the MQ Cluster.

Submit a Comment