ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Asynchronous Messaging Made Easy With Spring JMS
Pages: 1, 2, 3, 4, 5


Table 3 below shows the different technologies and open source frameworks I used in the sample application listed by the application tier.

Table 3. Frameworks used in the JMS application

Tier Technology/Framework
MVC Spring MVC
Service Spring Framework (version 2.1)
JMS Provider JBoss MQ (version 4.0.2)
JMS Console Hermes
IDE Eclipse 3.1

JMS Resource Setup Using Hermes

To process a message asynchronously, first we need the message queues to send and receive messages. We can create a new message queue using the configuration XML file in JBoss and then browse the queue details using a JMS console. Listing 1 shows the XML configuration snippet for the JMS configuration. (This should be added to the jbossmq-destinations-service.xml file located in the %JBOSS_HOME%\server\all\deploy-hasingleton\jms directory.)

Listing 1. Configuration of the JMS queue in JBoss MQ Server

<!--  Credit Request Send Queue  -->
<mbean code="org.jboss.mq.server.jmx.Queue"
  <depends optional-attribute-name="DestinationManager">

<!--  Credit Request Receive Queue  -->
<mbean code="org.jboss.mq.server.jmx.Queue"
  <depends optional-attribute-name="DestinationManager">

Now, let's look at how to browse a message queue using a JMS tool called Hermes. Hermes is a Java Swing application that can be used to create, manage, and monitor JMS destinations in JMS providers such as JBossMQ, WebSphereMQ, ActiveMQ and Arjuna servers. Download Hermes from its website and extract the .zip file to a local directory (for example, c:\dev\tools\hermes). Once it's installed, double-click the file hermes.bat (located in the bin directory) to launch the program.

To configure JBossMQ server in Hermes, refer to this demo on the Hermes website. It has excellent step-by-step visual instructions for JBoss MQ configuration. Enter the following information when configuring a new JNDI initial context.

  • providerURL = jnp://localhost:1099
  • initialContextFactory = org.jnp.interfaces.NamingContextFactory
  • urlPkgPrefixes = org.jnp.interfaces:org.jboss.naming
  • securityCredentials = admin
  • securityPrincipal = admin

Enter queue/CreditRequestSendQueue and queue/CreditRequestReceiveQueue when you create new destinations. Figure 2 shows the main screen of the JMS console with the new message queues created for the sample JMS application.

Thumbnail, click for full-size image.
Figure 2. Screenshot of all destinations in Hermes. (Click on the screen shot to open a full-size view)

Figure 3 below shows a screenshot of the Hermes JMS console with message queue details after sending a few messages to CreditRequestSendQueue from the message sender class. You can see there are five messages in the queue and the console shows the message details such as message ID, message destination, time stamp, and the actual message.

Thumbnail, click for full-size image.
Figure 3. Screenshot of queue details in Hermes. (Click on the screen shot to open a full-size view)

Pages: 1, 2, 3, 4, 5

Next Pagearrow