ActiveMQ point-to-point messaging domain

This tutorial will show you how we can send a message to Queue using point-to-point messaging system in Apache ActiveMQ. For more information on point-to-point messaging system please read tutorial http://www.roytuts.com/configure-jms-client-using-glassfish-3/

Before you move forward please read the tutorial http://www.roytuts.com/apache-activemq-configuration-in-windows/ for configuring ActiveMQ but do not create any Queue.

Now we will look into the following steps in order to implement point-to-point messaging system.

1. Create a class called MessageProducer that will produce message or send message to the destination – Queue.

2. Create a class called MessageConsumer that will receive message from the destination – Queue.

3. Create a class called JmsConstants that will hold all constants related to JMS.

4. Create a main class that will run the MessageProducer.

5. Create a main class that will run the MessageConsumer.

6. Run the MessageProducer.

Output

7. Go to the ActiveMQ Web Console and click on Queues. You will see one message is enqueued in the IN_QUEUE and pending for consumption because at this moment the MessageConsumer is not up and running.

ActiveMQ MessageProducer sends a message

8. Run the MessageConsumer.

Output

9. Now again click on Queues in ActiveMQ Web Console. You will not see any message in the IN_QUEUE because as soon as you ran the MessageConsumer the message has been consumed by the MessageConsumer and now you will see one message has been dequeued.

ActiveMQ no message pending in IN_QUEUE

Note: if you run the MessageConsumer first then MessageProducer then you will not see any message pending in the IN_QUEUE.

Here is the pom.xml

 

That’s all. Thank you for reading.

Soumitra

Software Professional, I am passionate to work on web/enterprise application. For more information please go to about me. You can follow on Twitter. You can be a friend on Facebook or Google Plus or Linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.