1

Please suggest how to prevent insert duplicate records in RabbitMQ Queue using java using values.

Example :

{
  "jsonObject" : {
     "code" : "ABC",
     "number" : "123456",
     "Name"  : "Narasimha"
  } 
}

if one record available in RabbitMq . if try to insert one more record with same code and number it should not allow to insert RabbitMQ.

Narasimha
  • 109
  • 2
  • 13

1 Answers1

2

You cannot do that with RabbitMQ, the amqp body is a buffer and RMQ does not know anything about the body content.

You should handle duplications consumer side.

Read here: https://www.rabbitmq.com/reliability.html

At the Consumer

In the event of network failure (or a node crashing), messages can be duplicated, and consumers must be prepared to handle them. If possible, the simplest way to handle this is to ensure that your consumers handle messages in an idempotent way rather than explicitly deal with deduplication.

Gabriele Santomaggio
  • 21,656
  • 4
  • 52
  • 52