Sunday, December 21, 2008

Consuming a JMS Message from ActiveMQ using Spring Message Driven POJO

In my last post, I had shown how you can post a JMS message to a ActiveMQ queue. In this post I will show the reverse process. I will not try to consume this message using a Spring Message Driven POJO. I assume your familiarity with Spring MDP. If not you can look here - http://static.springframework.org/spring/docs/2.5.x/reference/jms.html
The operation that I intend to carry out is depicted in Figure 1.
image
Figure 1 - Consuming JMS message using Spring MDP


Step 1 - Create the message listener.
Listing 1 - EventMessageConsumer.java

Step 2 - Wire up the bean in Spring configuration
Listing 2 - spring-activemq-config.xml

Step 3  - Test
Finally you can see the results of message produced and consumed in the Admin web console as shown in Figure 2.
image
Figure 2 - Queue statistics

No comments:

Post a Comment