25.02.2015 Views

Introducing Spring Framework

Introducing Spring Framework

Introducing Spring Framework

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 11 ■ Integrating Your <strong>Spring</strong> Application with External Systems<br />

Figure 11-5. The Message Is Listed and Ready<br />

150<br />

Figure 11-5 shows the message that you sent to the queue.<br />

<strong>Spring</strong> JMS<br />

Next, you are going to create a consumer that will consume that message. The <strong>Spring</strong> <strong>Framework</strong> already has a<br />

template (for sending JMS messages to any JMS broker) and a Simple Listener container (that connects to a JMS<br />

broker and listens for any new messages incoming from a queue or topic). Listing 11-2 shows the consumer you are<br />

going to use to consume the XML message from the Apache ActiveMQ container.<br />

Listing 11-2. JMSConsumer.java<br />

package com.apress.isf.spring.jms;<br />

import javax.jms.JMSException;<br />

import javax.jms.Message;<br />

import javax.jms.MessageListener;<br />

import javax.jms.TextMessage;<br />

import org.springframework.beans.factory.annotation.Autowired;<br />

import org.springframework.stereotype.Component;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!