且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

RabbitMQ插件删除重复的消息

更新时间:2023-02-16 14:19:36

好,我已经阅读了RabbitMQ内部架构,并发现这是不可能的.所以有人寻找它的方法.

Ok, i've read about RabbitMQ inner architecture and find out it's impossible. So the way around for somebody looking for it.

  1. 仅在邮件正文中发送文档ID
  2. 为工作者创建键值存储(为此,我使用memcached).关键是ID值是为此ID运行的上一个工作程序的时间戳.
  3. 当worker收到消息时,它将检查消息时间戳是否大于键值存储中的消息时间戳.如果是这样,则更新存储中的时间戳并运行任务,否则就跳过它.
  1. Send only document ID in message body
  2. Create a key-value store for worker (i use memcached for this). Key is ID value is timestamp of last worker run for this ID.
  3. When worker receives the message it checks if message timestamp greater then the one from key-value store. If it is, then update timestamp in the store and run the task, otherwise just skip it.