英文:
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>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论