Introducing Spring Framework

Introducing Spring Framework Introducing Spring Framework

25.02.2015 Views

Chapter 11 ■ Integrating Your Spring Application with External Systems Figure 11-4. The “Message sent!” Message After pasting the XML contents (from Listing 11-1), see Figure 11-3. Click the Send Message button. This will send the XML message to the mydocumentsQueue; take a look at Figure 11-4. Figure 11-4 displays a “Message sent!” message in green. This means that your message is now waiting in the queue. And if you click the Browse button (next to the Send button) you can see the message listed and ready to be consumed by any client, as shown in Figure 11-5. 149

Chapter 11 ■ Integrating Your Spring Application with External Systems Figure 11-5. The Message Is Listed and Ready 150 Figure 11-5 shows the message that you sent to the queue. Spring JMS Next, you are going to create a consumer that will consume that message. The Spring Framework already has a template (for sending JMS messages to any JMS broker) and a Simple Listener container (that connects to a JMS broker and listens for any new messages incoming from a queue or topic). Listing 11-2 shows the consumer you are going to use to consume the XML message from the Apache ActiveMQ container. Listing 11-2. JMSConsumer.java package com.apress.isf.spring.jms; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageListener; import javax.jms.TextMessage; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component;

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

Figure 11-4. The “Message sent!” Message<br />

After pasting the XML contents (from Listing 11-1), see Figure 11-3. Click the Send Message button. This will send<br />

the XML message to the mydocumentsQueue; take a look at Figure 11-4.<br />

Figure 11-4 displays a “Message sent!” message in green. This means that your message is now waiting in the<br />

queue. And if you click the Browse button (next to the Send button) you can see the message listed and ready to be<br />

consumed by any client, as shown in Figure 11-5.<br />

149

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

Saved successfully!

Ooh no, something went wrong!