如何知道消息在RabbitMQ中的位置

huangapple go评论70阅读模式
英文:

How to know where a message is in RabbitMQ

问题

我正在使用Go编写一个服务,并使用RabbitMQ进行消息传递。我需要在消息头中添加信息,该信息应包含消息流经的位置,即当消息进入一个位置时,应将exchange名称或queue名称添加到消息头中。

有人可以告诉我如何实现这个功能吗?

英文:

I am writing a service using Go and using RabbitMQ for messaging. I need to add information in the header that should contain where the message flows through, it should add the exchange name or the queue name in the message header as and when it enters one.

Can someone tell me how this can be done?

答案1

得分: 0

每个传递的消息都有一组属性。其中两个属性是用于路由消息的交换机和路由键。根据这些信息,您还可以根据交换机的类型确定队列名称。

如果您需要知道消息何时发布,可以使用此插件-https://github.com/rabbitmq/rabbitmq-message-timestamp


注意:RabbitMQ团队监视rabbitmq-users邮件列表(https://groups.google.com/forum/#!forum/rabbitmq-users),并且只有在某些情况下才会回答StackOverflow上的问题。

英文:

Every delivered message has a set of properties. Two of these are the exchange used to route the message, and the routing key. Depending on the type of exchange you can also figure out the queue name based on this information.

https://www.rabbitmq.com/amqp-0-9-1-quickref.html

If you need to know when a message is published you can use this plugin - https://github.com/rabbitmq/rabbitmq-message-timestamp


<sub><b>NOTE:</b> the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.</sub>

huangapple
  • 本文由 发表于 2022年3月8日 11:26:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/71389693.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定