Embedded ActiveMQ and Spring JMS Integration

This tutorial will show you how we can run Apache ActiveMQ with Spring in the embedded mode using point-to-point messaging domain. For more information on point-to-point messaging system please read tutorial http://www.roytuts.com/configure-jms-client-using-glassfish-3/

For running ActiveMQ in embedded mode we do not need to run the ActiveMQ server manually by executing command in command prompt.

Now we will look into the following steps in order to implement point-to-point messaging system using Spring and embedded ActiveMQ.

Prerequisites

Eclipse Kepler

Maven 3.x

JDK 1.8

Spring 4.x.x

Apache ActiveMQ 5.11.1

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

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

3. Create an XML property file that will hold all key/value pairs for the application. Put this file under src/main/resources

4. Create an XML configuration file that will hold all JMS related configuration for the application. Put this file under src/main/resources/jms

5. Create an XML file that will load all other resources and configure support for annotation in the application. Put this file under src/main/resources/spring

6. Create a test class under src/test/java that will run the MessageProducer.

7. Create an XML file which will run ActiveMQ server in embedded mode.

8. Run the EmbeddedMessageProducerTest.

Output

Note: In embedded mode you would not be able to open web console for the destination because the ActiveMQ server running in embedded mode and once the work is done then JVM terminates, so the ActiveMQ server.

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.