有没有办法验证RabbitMQ的路由密钥格式或消息模式?
我正在使用RabbitMQ作为消息经纪人。我有一个API,可以接受另一个过程中的消息,并使用Python Pika库将消息发送到RabbitMQ。我想验证两件事:
- 路由键的格式是预期的格式(例如,我们希望路由键是
< data-; data-type>。。成功|失败>
- 消息遵循消费者期望的JSON架构。
我知道我可以在API级别上进行验证路由键,如果此验证在Pika库中可行。
I am using RabbitMQ as a message broker. I have an An API that accepts the message from another process and uses the python pika library to send the message to RabbitMQ. I want to validate two things:
- The format of the routing key is in an expected format (for example, we expect the routing key to be something like
<data-type>.<update-stage>.<success|failure>
- The message follows the json schema expected by the consumers.
I know that I can easily do the validation at the API level, but I was wondering if RabbitMQ itself has any way to register schemas or validate the format of the routing key, and if this validation is doable within the pika library.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
No中可行的验证,这是不受欢迎的。
您应该能够通过自定义的RabbitMQ插件来完成它。您可以使用 Message timestamp插件作为指导。
实际上,这是一个足够有趣的问题,我会试一试。订阅此存储库 -
https://github.com/lukebakken/lukebbitmq-message-message-validator
我在那里导入了消息时间戳插件代码,并将其迁移到验证器。
请在此处打开一个GitHub问题以自我介绍,我将为您的存储库添加您作为合作者。
No, this is not supported out-of-the box.
You should be able to accomplish it via a custom RabbitMQ plugin. You could use the Message Timestamp plugin as a guide.
In fact, this is an interesting enough problem I will give it a shot. Subscribe to this repository -
https://github.com/lukebakken/rabbitmq-message-validator
I have imported the message timestamp plugin code there and will migrate it to a validator.
Please open a GitHub issue there to introduce yourself and I will add you as a collaborator to my repository.