Search code examples
javaspringintegrationrabbitmqamqp

Does Spring Integration RabbitTemplate publish to persistent queue by default?


I have a scheduled task that performs the following bit of code:

    try {
        rabbitTemplate.convertAndSend("TEST");
        if (!isOn()) {
            turnOn();
        }
    }
    catch (AmqpException e) {
        if (isOn()) {
            turnOff();
        }
    }

Everything works just fine. It sends this message to the default "AMQP default" exchange. I do not have a consumer on the other end to consume these messages because I am just ensuring that the server is still alive. Will these messages accumulate over time and cause a memory leak?

Thanks! K


Solution

  • Do you have a RabbitMQ user interface? You should be able to see the queues that are being created and whether they are persistent or not. Last time I checked, the default behaviour of Spring AMQP is to create persistent queues.

    Have a look at the RabbitMQ Management Plugin: http://www.rabbitmq.com/management.html Using the RabbitMQ Management Plugin, you can also consume messages that you've published via your code.

    Regarding what happens with the messages, they will just pile up and pile up until RabbitMQ hits its limits, then it will no longer accept messages until you purge the queue or consume those messages. With the default RabbitMQ settings, I was able to send about 4 million simple text messages to the queue before it started blocking.