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...

Creating and Configuring Glassfish Cluster with MQ Cluster

1. Install Glassfish with cluster profile: a. Make sure ANT_HOME environment variable points to the ant instation folder. For example: “C:Program Filesapache-ant-1.7.1” b. Make sure PATH variable has ant’s bin folder. For example: “C:Program Filesapache-ant-1.7.1bin” c. Go to the folder where glassfish jar (glassfish-installer-v2.1.1-b31g-windows.jar) is extracted. d. Run: “ant –f setup-cluster.xml”. You should see “Build Successful” message. e. Follow the installation on all the systems where Glassfish needs to be installed 2. Start glassfish domain. a. Choose one of the Glassfish installation server as Domain Administration Server (DAS). The domain administration server is used to administer all the servers in the cluster. b. Start the Domain Administration server. Go to glassfishbin folder and Run: “asadmin start-domain domain1” 3. Create Node agents a. Node agents need to be created on each system where we need a Glassfish cluster instance. b. Go to DAS admin console. c. Navigate to Node Agents on left hand tree d. Click “New” for creating node agents. e. Give a node agent name. Click Ok f. We need to run “asadmin create-node-agent” command on all the host machines which will participate in this cluster. For now, Click Ok. g. Follow the above steps to create node agents for each machine. h. The screen should look like this: i. Go to a system which will participate in the cluster. Open command prompt and change directory to <GlassFishDir>/glassfish/bin. j. Run “asadmin create-node-agent –host <host or IP> –port 4848 <node-agent-name>”. The node-agent-name should be exactly same as what we gave in admin console. The host or IP is DAS host / IP. If the system is not able to...