Glassfish 3.1 Demo With Admin Console

GlassFish Cluster with MQ Local Mode Enhanced (HA) Cluster




1. Start the domain

     cd $AS_HOME/bin
./asadmin start-domain

2. Create appserver cluster

Clusters – New – cluster1 - OK


3. Set JMS integration mode to LOCAL

Configurations – Cluster1-config – Java Message Service – Type – LOCAL – Save



4. Configure JMS cluster

Configurations – Cluster1-config – Availability Service – JMS Availability - <update attributes> - Save

[Add GUI Screen Shot here when issue 15684 is fixed.]

NOTE: This GUI functionality is broken. See issue 15684 for details. The workaround is to use following CLI steps.

4.1 Specify DB password in the “as_passfile” using the key “AS_ADMIN_JMSDBPASSWORD”

$ more /tmp/mq45demo/as_passfile 

AS_ADMIN_JMSDBPASSWORD=mysqlmysql

4.2 Use CLI to Configure JMS cluster:

$ asadmin --passwordfile /tmp/mq45demo/as_passfile configure-jms-cluster --clustertype=enhanced --dbvendor=mysql –dbuser=root --dburl="jdbc:mysql://mqsflinux1.us.oracle.com:5000/mqdb" cluster1

JMS Cluster Configuration updated for Cluster cluster1
Command configure-jms-cluster executed successfully.

5. Create instance instance1

Clusters – cluster1 – Instances – New – instance1 – OK

6. Similary, create instance instance2

Clusters – cluster1 – Instances – New – instance2 – OK

7. Copy the mysql jar file (mysql-connector-java-bin.jar) to the $AS_HOME/mq/lib/ext

8. Start the instances

check “instance1” and “instance2” - click on Start. Wait until the status is shown as “Running”.

9. Create jms resources

9.1 Resources – JMS Resources – Destination Resources – New – inboundQueue (see values below)

9.2 Resources – JMS Resources – Connection Factories – New – outboundQueueFactory (see values below).

10. Deploy the simplemdb app.

App Details:



11: Receiver

11.1 Find out JMS Port numbers for instance1.
clusters - cluster1 - instances - instance1 - properties - JMS_PROVIDER_PORT = 27678

11.2 Run Receiver on instance1. Use $JMS_PROVIDER_PORT for instance1.


java -DimqBrokerHostPort=27678 Receiver

12: Sender

12.1 Find out the JMS Port numbers for instance2.
clusters - cluster1 - instances - instance2 - properties - JMS_PROVIDER_PORT = 27679

12.2 Run Sender on instance2. Use $JMS_PROVIDER_PORT for instance2.


java -DimqBrokerHostPort=27679 Sender

Sending 10 messages to queue inboundQueue
Msg Sent : Hello World: Text message 0
Msg Sent : Hello World: Text message 1
Msg Sent : Hello World: Text message 2
Msg Sent : Hello World: Text message 3
Msg Sent : Hello World: Text message 4
Msg Sent : Hello World: Text message 5
Msg Sent : Hello World: Text message 6
Msg Sent : Hello World: Text message 7
Msg Sent : Hello World: Text message 8
Msg Sent : Hello World: Text message 9

13. Verify that all the 10 messages are received by the Receiver.

Receiving messages from queue outboundQueue
Received message: Hello World: Text message 4
Received message: Hello World: Text message 2
Received message: Hello World: Text message 1
Received message: Hello World: Text message 8
Received message: Hello World: Text message 7
Received message: Hello World: Text message 3
Received message: Hello World: Text message 9
Received message: Hello World: Text message 5
Received message: Hello World: Text message 0
Received message: Hello World: Text message 6
Total Number of Msgs Received from outboundQueue : 10


14. Cleanup: (Same GUI steps as the other configuration. See “glassfish-single-instance-mq-embedded” for details) Equivalent CLI: /asadmin undeploy --target cluster1 simplemdb ./asadmin delete-jms-resource --target cluster1 inboundQueue ./asadmin delete-jms-resource --target cluster1 outboundQueue ./asadmin delete-jms-resource --target cluster1 outboundQueueFactory

Version 1.0 Last Update: Jan 24, 2011 harshad.vilekar@...