Home > Net >  RabbitMQ's receiveAndConvert for clustered environment
RabbitMQ's receiveAndConvert for clustered environment

Time:10-14

I have this method implemented in a SpringBoot application

@Scheduled(fixedDelay = 5000)
public void pullMessage() {
    MessageDTO message = null;

    try {
        message = rabbitTemplate.receiveAndConvert(properties.getQueueName(), new ParameterizedTypeReference<MessageDTO>() {});
    // more code here...


}

every 5 seconds I'm pulling a message from RabbitMQ and processing something with it. The application is running on Kubernetes and right now I have to duplicate the POD. In this scenario, could the two pods pull the same message?

CodePudding user response:

If the queue is the same for all the instances, then no: only one consumer takes a message from a queue. That's fundamental purpose of the queue pattern at all.

See AMQP docs for publish-subscribe patterns: https://www.rabbitmq.com/tutorials/tutorial-three-java.html

  • Related