O'Reilly logo

Hands-On High Performance with Spring 5 by Dinesh Radadiya, Prashant Goswami, Pritesh Shah, Subhash Shah, Chintan Mehta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Configuring an exchange

Now, we need to create an AMQP exchange, to which a message producer will send a message. The Exchange interface represents an AMQP exchange. There are four implementations of the Exchange interface type: DirectExchange, TopicExchange, FanoutExchange, and HeadersExchange. We can use any exchange type based on our requirements. We will use DirectExchange using the following code:

@Beanpublic DirectExchange exchange() {    return new DirectExchange(RABBIT_MESSAGE_EXCHANGE);}

The exchange() method creates DirectExchange with a specific name defined under RABBIT_MESSAGE_EXCHANGE. We can also set the durability using the durable flag. We need to pass it along with the second constructor argument as a Boolean type.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required