Consuming messages with Spring Messaging

Spring AMQP provides the @RabbitListener annotation; it will configure the subscriber for the desired queue, it removes a lot of infrastructure code, such as connect to RabbitListenerConnectionFactory, and creates a consumer programmatically. It makes the creation of queue consumers really easy.

The spring-boot-starter-amqp provides some automatic configurations for us. When we use this module, Spring will automatically create a RabbitListenerConnectionFactory for us and configure the Spring converters to convert JSON to domain classes automatically.

Pretty simple. Spring AMQP really provides a super high-level abstraction for developers.

Let's see an example which will be used in our application soon: ...

Get Spring 5.0 By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.