DEV Community

loizenai
loizenai

Posted on

RabbitMq Queue Durability and Persistent MessageDelivery | SpringBoot

https://grokonez.com/spring-framework/spring-amqp/rabbitmq-queue-durability-persistent-messagedelivery-springboot

RabbitMq Queue Durability and Persistent MessageDelivery | SpringBoot

In the tutorial, JavaSampleApproach will show you how to work with RabbitMq Queue Durability and Persistent MessageDelivery.

Related posts:

I. Technologies

– Java 8
– Maven 3.6.1
– Spring Tool Suite – Version 3.8.1.RELEASE
– Spring Boot: 1.5.7.RELEASE
– RabbitMq

II. RabbitMq Queue Durability and Persistent MessageDelivery

RabbitMq Queue has 2 kind of durability: {Durable, Transient}.

  • Durable queue is a solution for re-declared persistent messages during broker restarts if broker is taken down.

springboot rabbitmq durable queue - architecture

Scenarios with above design:

  • When sending 2 messages {a persistent message, a trasient message} to exchange X, all messages will be delivered to 2 queues {Q1, Q2}.
  • Stop RabbitMq service, then re-start it -> just a persistent message will be re-declared in durable queue Q1.

With Spring framework, default message is PERSISTENT mode:


package org.springframework.amqp.core;
...

public class MessageProperties implements Serializable {
    ...
    
    public static final MessageDeliveryMode DEFAULT_DELIVERY_MODE = MessageDeliveryMode.PERSISTENT;
    ...
    
}

We can change the delivery mode as below:

More at:

https://grokonez.com/spring-framework/spring-amqp/rabbitmq-queue-durability-persistent-messagedelivery-springboot

RabbitMq Queue Durability and Persistent MessageDelivery | SpringBoot

Top comments (0)