Posts Tagged jms

Using HermesJMS to browse GlassFissh’s JMS queues

GlassFish includes Sun’s implementation of JMS , known as OpenMQ . When developing SOA applications with Java CAPS or OpenESB , you will most probably end up using JMS queues and topics as loosely coupled communication mechanism between components of your application.

However, as great are GlassFish and OpenMQ, they lack a graphical tool allowing to browse queues and topic. Developing JMS applications without such a tool is a frustrating task, to say the least.

Here comes HermesJMS. Quoted from their web site :

HermesJMS is an extensible console that helps you interact with JMS providers making it easy to browse or search queues and topics, copy messages around and delete them. It fully integrates with JNDI letting you discover administered objects stored, create JMS sessions from the connection factories and use any destinations found”

Configuring HermesJMS to connect to OpenMQ is not intuitive at all and I found very few resources on the web explaining how to do it.

At this stage, I would like to thank Michael Czapski and Thomas Barrett for having showed me the steps required to configure HermesJMS and for all the work they did to prepare a great CEC 2008.

Step 1 : Start Hermes JMS

The easiest way to start Hermes JMS is using Java Web Start. You can do that from their web site or using the icon below (requires Java SE 6+, if you have older versions of Java, other links are provided on Hermes JMS’ web site)

Note that it will only work if your Java MQ is installed to use default port 7676.

Step 2 : Create a JavaMQ session

Replace <new> with JavaMQ and click the Apply button.

Step 3 : Add Java MQ JARs files to the classpath

Click on the Providers Tab on the bottom of the screen, right click anywhere inside the Classpath Groups pane and choose Add Group.

Name the group JavaMQCLasspahGroup (or whatever meaningful name you want). Right-click on the long button called Library and choose Add JAR(s).

Navigate to your GlassFish application server’s imq/lib directory. For OpenESB installed to OPENESB_HOME it will be something like : $OPENESB_HOME\glassfish-v2-ur2-b04-patch-20080929\imq\lib

This should work whether the imq/lib comes from Java MQ 4.1, OpenESB installation, GlassFishESB installation or Java CAPS 6 installation.

Choose the 10 following JARs. Not all may be required by we did not spend the time figuring out the minimum necessary set.

  • fscontext.jar

  • imq.jar

  • imqadmin.jar

  • imqbroker.jar

  • imqjmx.jar

  • imqutil.jar

  • imqxm.jar

  • jaxm-api.jar

  • jhall.jar

  • jms.jar

Allow Hermes to scan the JARs.

Once the JARs are scanned the Library will list all the JARs. Click the Apply button. Your screen should now look like this :

Click on Apply, then OK

Right-click the JavaMQ session and choose Edit to open configuration dialogue again.

Pull down the Loader menu and choose the JavaMQClasspathGroup. Pull down the Class menu and choose the com.sun.messaging.QueueConnectonFactory class. Click OK

Step 4 : Add an existing JMS queue / topic to your session

The last step is to actually add the queues and topics you want to monitor

Right-click JavaMQ session and choose New->Add queue …

and be sure to choose the name of an existing queue or topic.

Step 5 : Enjoy browsing your queues and topics

Once the Java MQ session is configured and queues of interest are configured we can interact with the Java MQ broker, view messages in destinations, truncate destinations (delete all messages) and so on. The functionality of Hermes JSM can be used as required.

UPDATE : OpenMQ FAQ now has a topic on HermesJMS Integration.  It also describes how to connect to a remote broker, not running on the localhost.