In previous post, I explained the usage of message acknowledgement. What if RabbitMQ stopped working (or) crashes ? We
need to make sure queue is durable.
Following
statements are used to make a queue durable.
boolean durable = true;
channel.queueDeclare("queueName",
durable, false, false, null);
Above statements must applied to both the producer and consumer code.
By using
above statement we make sure that queue persist, even if the RabbitMQ restarts.
Now we need to mark our messages as persistent.
Following
statement is used to persist messages.
channel.basicPublish("",
"task_queue", MessageProperties.PERSISTENT_TEXT_PLAIN,
message.getBytes());
No comments:
Post a Comment