Creating the RabbitMQ queue listener

Let's create our MailQueueConsumer class, which will listen to the RabbitMQ queue. The class should look like this:

package springfive.airline.mailservice.domain.service;import com.fasterxml.jackson.databind.ObjectMapper;import java.io.IOException;import javax.annotation.PostConstruct;import lombok.extern.slf4j.Slf4j;import lombok.val;import org.springframework.beans.factory.annotation.Value;import org.springframework.stereotype.Service;import reactor.rabbitmq.Receiver;import springfive.airline.mailservice.domain.Mail;@Service@Slf4jpublic class MailQueueConsumer {  private final MailSender mailSender;  private final String mailQueue;  private final Receiver receiver;  private final ObjectMapper mapper; public ...

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.