activemq-artemis/examples/features/standard/exclusive-queue
Clebert Suconic 37cc298973 [maven-release-plugin] prepare release 2.18.0 2021-08-09 11:58:27 -04:00
..
src/main NO-JIRA Fixing some javadoc statements 2020-07-09 12:23:46 -04:00
pom.xml [maven-release-plugin] prepare release 2.18.0 2021-08-09 11:58:27 -04:00
readme.md NO-JIRA a few example updates 2019-06-20 11:42:00 -04:00

readme.md

JMS Exclusive Queue Example

To run the example, simply type mvn verify from this directory, or mvn -PnoServer verify if you want to start and create the broker manually.

This example shows you how to configure ActiveMQ Artemis so all messages are delivered to the same consumer

ExclusiveQueueExample.java

The broker is configured (using address-settings), so that the queue is exclusive and will deliver all messages to the same consumer

<address-settings>
   <address-setting match="my.exclusive.queue">
      <default-exclusive-queue>true</default-exclusive-queue>
   </address-setting>
</address-settings>

ExclusiveQueueClientSideExample.java

The JMS Queue is auto created from the client code and uses the exclusive parameter.

Queue queue = session.createQueue("client.side.exclusive.queue?exclusive=true");

This example also shows that all remaining messages are sent to another consumer when the first consumer (that was receiving all messages), is closed.