JBoss JMS configuration

The Java Messaging Service (JMS) has been implemented by means of different providers in the releases 4.x, 5.x and 6.x of JBoss application server. This tutorial explains how to configure and run some JMS destinations using a managed JMS environment (consumer located in JBoss AS) or a standalone JMS application.

The JMS API stands for Java Message Service Application Programming Interface, and it is used by applications to send asynchronous business-quality messages to other applications. In the messaging world, messages are not sent directly to other applications. Instead, messages are sent to destinations, known as queues or topics.

Applications sending messages do not need to worry if the receiving applications are up and running, and conversely, receiving applications do not need to worry about the sending application's status. Both senders, and receivers only interact with the destinations.

The JMS API is the standardized interface to a JMS provider, sometimes called a Message Oriented Middleware (MOM) system.

In order to run a JMS application on JBoss AS you need to configure:

  • The JMS destionation on JBoss AS
  • The JMS libraries on the client

Configuring JMS destinations on JBoss

Case 1: WildFly 10 (ArtemisMQ)

JBoss AS 7 JMS destinations can be configured either by adding them in the core configuration file (standalone.xml/domain.xml) or via management interfaces such as the CLI :

Via CLI:

Add JMS queue:

[standalone@localhost:9999 /] jms-queue add --queue-address= jms.queue.ExampleQueue --entries=java:/jms/queue/exampleQueue,java:/jboss/exported/jms/queue/exampleQueue                  

Add JMS Topic:

[standalone@localhost:9999 /] jms-topic add --topic-address=jms.topic.ExampleTopic --entries=java:/jms/topic/exampleTopic,java:/jboss/exported/jms/topic/exampleTopic                   

 

Please note that the JNDI binding "java:/jboss/exported/jms/[destination]" is only required if you are connecting to your JMS Destination from a remote JMS Client

 

Via the configuration file:

<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
    <server name="default">
         . . . .  
        <jms-queue name="jms.queue.ExampleQueue" entries="java:/jms/queue/exampleQueue java:/jboss/exported/jms/queue/exampleQueue"/>
        <jms-topic name="jms.topic.ExampleTopic" entries="java:/jms/topic/exampleTopic java:/jboss/exported/jms/topic/exampleTopic"/>

    </server>
</subsystem>

Case 2: JBoss AS 7 / JBoss EAP 6 (Hornet Q)

JBoss AS 7 JMS destinations can be configured either by adding them in the core configuration file (standalone.xml/domain.xml) or via management interfaces such as the CLI :

Via CLI:

Add JMS queue:

[standalone@localhost:9999 /] jms-queue add  --queue-address=queue1 --entries=queues/queue1                    

Add JMS Topic:

[standalone@localhost:9999 /] jms-topic add  --topic-address=topic1 --entries=topics/topic1                    

Via the configuration file:

<subsystem xmlns="urn:jboss:domain:messaging:1.1">

 <hornetq-server>

    . . . . . . . . . . .
    <jms-destinations>
       <jms-queue name="testQueue">
           <entry name="queue/test"/>
       </jms-queue>
       <jms-topic name="testTopic">
           <entry name="topic/test"/>
       </jms-topic>
    </jms-destinations>

 </hornetq-server>
</subsystem>

Case 3: JBoss AS 6 (HornetQ)

HornetQ configuration is located in JBoss 6 in deploy\hornetq.sar. You can add new Topic/Queues by adding them into hornetq-jms.xml file.

<queue name="testQueue">
  <entry name="/queue/queueA"/>
</queue>

<topic name="testTopic">
  <entry name="/topic/topicA"/>
</topic>

Case 4: JBoss AS 5 (JBoss Messaging)
If you are running JBoss 5, which ships with JBoss messaging you can add the following XML (-service.xml) to your deploy folder:

<mbean code="org.jboss.jms.server.destination.QueueService"
 name="jboss.messaging.destination:service=Queue,name=queueA"
 xmbean-dd="xmdesc/Queue-xmbean.xml">
  <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
  <depends>jboss.messaging:service=PostOffice</depends>
</mbean>

<mbean code="org.jboss.jms.server.destination.TopicService"
 name="jboss.messaging.destination:service=Topic,name=topicA"
 xmbean-dd="xmdesc/Topic-xmbean.xml">
  <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
  <depends>jboss.messaging:service=PostOffice</depends>
</mbean>   

Case 5: JBoss AS 4 (JBoss MQ)
If you using JBoss older JMS provider, you can add the following XML (-service.xml) to your deploy folder:

 <mbean code="org.jboss.mq.server.jmx.Queue"
 name="jboss.mq.destination:service=Queue,name=queueA">
  <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
</mbean>

<mbean code="org.jboss.mq.server.jmx.Topic"
 name="jboss.mq.destination:service=Queue,name=topicA">
  <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
</mbean>

Related articles available on mastertheboss.com

How to configure a Queue in JBoss ?

This article has been moved here: JBoss JMS configuration

How to create a Queue with Jmx Console ?

  Bring up the JMX Console in your browser and look for the sect

JBoss JMS Queue example

The following article shows how to create a simple JMS Queue Prod

JBoss JMS Topic example

The following article shows how to create a simple JMS Topic Publ

JBoss HornetQ simple tutorial

HornetQ is an open source project to build a multi-protocol, embe

How do I configure a Queue/Topic to work in a cluster?

  JBoss AS 5 Just set the Clustered attribute to "true" in your

Follow us on Twitter