Introducing Spring Framework

Introducing Spring Framework Introducing Spring Framework

25.02.2015 Views

Chapter 11 ■ Integrating Your Spring Application with External Systems Listing 11-12 shows the rabbitmqProducer instance and the testSpringRabbitMQ_1() method. When this method is executed, it will send a document to the RabbitMQ broker by calling the rabbitmqProducer.send method. If you run Listing 11-12 with gradle :ch11:test, then you should have a message in the RabbitMQ broker. Figure 11-7 shows the queue and the message that is ready to be consumed. Figure 11-7. RabbitMQ: Queues Remember that you are pretending to be your friend that uses RabbitMQ, so how can you consume the messages from RabbitMQ? Listing 11-13 shows the XML configuration that will help you start consuming from RabbitMQ. Listing 11-13. mydocuments-context.xml

Chapter 11 ■ Integrating Your Spring Application with External Systems xsi:schemaLocation=" http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/ spring-jdbc-4.0.xsd http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms- 4.0.xsd http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/ spring-rabbit-1.2.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/springbeans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/ spring-context-4.0.xsd"> 166

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

Listing 11-12 shows the rabbitmqProducer instance and the test<strong>Spring</strong>RabbitMQ_1() method. When this<br />

method is executed, it will send a document to the RabbitMQ broker by calling the rabbitmqProducer.send method.<br />

If you run Listing 11-12 with gradle :ch11:test, then you should have a message in the RabbitMQ broker.<br />

Figure 11-7 shows the queue and the message that is ready to be consumed.<br />

Figure 11-7. RabbitMQ: Queues<br />

Remember that you are pretending to be your friend that uses RabbitMQ, so how can you consume the messages<br />

from RabbitMQ? Listing 11-13 shows the XML configuration that will help you start consuming from RabbitMQ.<br />

Listing 11-13. mydocuments-context.xml<br />

<br />

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

Saved successfully!

Ooh no, something went wrong!