Search Mastertheboss

Our eBooks

How to move JMS messages between destinations in WildFly

In this article, we will learn how to move messages from one JMS destination into another running on WildFly application server. We will also be using a filter to move messages selectively.

Let's start create the following example JMS Destinations:

jms-queue add --queue-address=queueA --entries=java:/jms/queue/queueA
jms-queue add --queue-address=queueB --entries=java:/jms/queue/queueB

Now, in order to move messages from queueA into queueB, you can use the following CLI command:


Also, consider that it is possible to use a filter when moving messages, using a message property as filter:


Please notice that one common use case is moving messages from the Dead Letter Queue to another Queue. In this case, in order to move selectively only messages that were destined to one destination (for example, queueA), you can filter through the property "_AMQ_ORIG_QUEUE". Here is, for example, how to restore messages from the DLQ (whose destination was queueA) into the queueB:


The same thing can also be done programmaticallly, by listening to the DLQ, and filtering messages to be moved within the onMessage method:

public void onMessage(Message message) {
   try {
        String queueDestination = "queueB";
            if (message.getStringProperty("_AMQ_ORIG_QUEUE").equals("queueA")) {
               Queue queue = session.createQueue(queueDestination);
               MessageProducer messageProducer = session.createProducer(queue);

    } catch (JMSException e) {



Related articles available on

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

© 2020 All Rights Reserved.

Please publish modules in offcanvas position.