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-6. The RabbitMQ Broker Main Page<br />

Next, you need to create the producer that will send messages to RabbitMQ. But how are you going to send AMQP<br />

messages? That’s right; by using <strong>Spring</strong>! The <strong>Spring</strong> <strong>Framework</strong> has <strong>Spring</strong> AMQP and <strong>Spring</strong> Rabbit modules that<br />

know how to talk AMQP and know how to communicate to RabbitMQ. Listing 11-10 shows the RabbitMQ producer.<br />

Listing 11-10. RabbitMQProducer.java<br />

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

import org.springframework.amqp.core.Message;<br />

import org.springframework.amqp.core.MessageProperties;<br />

import org.springframework.amqp.rabbit.core.RabbitTemplate;<br />

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

import org.springframework.stereotype.Component;<br />

import com.apress.isf.java.model.Document;<br />

import com.apress.isf.java.utils.XmlUtils;<br />

160

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

Saved successfully!

Ooh no, something went wrong!