Avoiding duplicated messages on JMS/ActiveMQ

前端 未结 5 1464
时光取名叫无心
时光取名叫无心 2020-12-14 08:54

Is there a way to suppress duplicated messages on a queue defined on ActiveMQ server?

I tried to define manually JMSMessageID, (message.setJMSMessageID(\"uniqueid\")

5条回答
  •  借酒劲吻你
    2020-12-14 09:28

    I doubt if ActiveMQ supports it natively, but it should be easy to implement an idempotent consumer. A way to do this would be to add a unique identifier to each message at the producer end, now at the consumer end using a store(db, cache etc), a check can be made to see if the message has been received before and continue to process based on that check.

    I see a previous stackoverflow question along the same lines - Apache ActiveMQ 5.3 - How to configure a queue to reject duplicate messages? , that may also help.

提交回复
热议问题