June 2018
Intermediate to advanced
408 pages
11h 23m
English
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.
Read now
Unlock full access