JBoss or EAP Clustering is a major reason why the JBoss Application Server is a true enterprise-class application server. With its fail-over, load-balancing, and distributed deployment features, JBoss Clustering provides the means to develop large, scalable, and robust applications.
Within this article, we will showcase the clustering of two JMS queues with the JBOSS application server. We are going to distribute our JMS queue on two JBOSS servers. We will deploy a Test application on both servers, which will provide a way to push messages into their respective queue. Additionally, we will push messages into one JBoss server, which will be distributed between both JMS queues on their respective servers. This kind of topology can be used to achieve scalable and highly available enterprise applications.
In our scenario, we are using the EAP 6.4 Beta version, which can be downloaded from the official JBoss website. The focus will be on making a clustering between two different Ubuntu machines.
Before setting up the clustering, we need to have a basic infrastructure:
To install Java, use the following commands:
§ sudo add-apt-repository ppa:webupd8team/java § sudo apt-get update
The JBoss EAP server provides two built-in cluster configuration files, named standalone-ha.xml and standalone-full-ha.xml, with the latter including CORBA support. We can find these files inside the folder accessed through: jboss-eap-6.4.0.Beta/jboss-eap-6.4/standalone/configuration.
The following steps should be used to configure the JBoss cluster onto two Ubuntu machines called Machine A (IP address 10.0.2.50) and Machine B (IP address 10.0.2.51).
<protocol type="TCPPING"> <property name="initial_hosts"> 10.0.2.50, 10.0.2.51 </property> <property name="num_initial_members"> 2 </property> <property name="port_range"> 0 </property> <property name="timeout"> 2000 </property> </protocol>
This addition should make the configuration look like the following screenshot. The port number 7600 is used for socket-binding fir the TCPPING protocol; we can change this port by modifying the port number of the <socket-binding name=”jgroupd-tcp”port=”7600″/> property.
<jms-destinations> <jms-queue name="testQueue2"> <entry name="jms/queue/testQueue2"/> <entry name="java:jboss/exported/jms/queue/testQueue2"/> </jms-queue> </jms-destinations>
Once we finish with the configurations, we can now start our servers. To do this, we first navigate to the jboss-eap-6.4.0.Beta/jboss-eap-6.4/bin folder on Server A and execute the following command at the terminal
./standalone.sh -c standalone-full-ha.xml -b=10.0.2.50 -bmanagement=10.0.2.50 -Djboss.node.name=serverA
Similarly, to start Server B, we navigate to the jboss-eap-6.4.0.Beta/jboss-eap-6.4/bin folder and execute the followign command at the terminal
./standalone.sh -c standalone-full-ha.xml -b=10.0.2.51 -bmanagement=10.0.2.51 -Djboss.node.name=serverB
The next step is to test the cluster. To do this, first download the test application here. This application pushes test data into the previously configured JMS queue named “testQueue2.” The messages sent to this queue will be distributed between both nodes of the cluster.
The downloaded application file, which is a war configuration, should be deployed on both servers. There are two ways to deploy any war/ear file on a JBoss EAP server:
In this example, we are going to use the second way to deploy our application to test the JBoss clustering.
First, we follow step 6.2.2 (“Creating a Management User in EAP 6”) on this guide to set-up a user account on the JBoss server, which will then allow us to open the admin console.
Because our servers are already running, we can visit URL 10.0.2.50:9990 and 10.0.2.51:9990 in the browser. Once we reach those addresses, a pop-up window will appear and ask us to enter a username and password. After successfully logging in, we should see the following admin screen.
The purpose of the deployed application is to push messages into the testQueue2. Because both JBoss servers are running in a clustered environment, the messages will be distributed onto both servers in a round robin fashion. To deploy the application, visit Deployments > Add and browse the downloaded war file.
After the application successfully deploys, the following screen should appear:
After the test application has been successfully deployed onto both servers, we can begin to test our configured clustering.
To test the clustering, we need to push some messages into our JMS queue. We begin by visiting the URL 10.0.0.50:8080/DemoJSM/MessageServlet?count=2, which will push two message into the JMS queue and allow us to see all messages distributed across both servers through the admin console.
To view the JMS queue detail, go to Runtime > JMS Destinations and click on “testQueue2.” Visible in Queue Metrics section for both servers’ admin console should be 1 message on each server, because we have only pushed 2 messages through with our test application.
We can also test the clustering with a higher message count, and would be able to see the messages being distributed on both servers’ JMS HornetQ queue.