怎么办误差EasyNetQ / RabbitMQ的处理 [英] How to do error handling with EasyNetQ / RabbitMQ

查看:666
本文介绍了怎么办误差EasyNetQ / RabbitMQ的处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用C#中的RabbitMQ与EasyNetQ库。我在这里使用的是发布/订阅模式。我仍然有,我希望有人能帮助我有几个问题:

I'm using RabbitMQ in C# with the EasyNetQ library. I'm using a pub/sub pattern here. I still have a few issues that I hope anyone can help me with:


  1. 当同时使用消息有一个错误,它会自动移到错误队列。我如何能实现重试(因此它被放回原始队列,当它无法处理X倍,它的移动到一个死信队列)?

  2. 至于我可以看到有总是的用于从所有其他队列将消息1错误队列。怎样才可以有每类错误队列,使每个队列都有自己相关的错误队列?

  3. 如何轻松地重试处于错误队列中的消息?我试过软管,但它甫一重新发布消息错误队列,而不是原始队列。我真的不喜欢这个选择是因为我不想被在控制台周围摆弄。最好,我正对错误队列程序。

有人吗?

推荐答案

您正在运行与EasyNetQ / RabbitMQ的问题是,它更加原始相比,像SQS或Azure的服务总线/队列等信息服务,但我会尽我的最好你指出正确的方向。

The problem you are running into with EasyNetQ/RabbitMQ is that it's much more "raw" when compared to other messaging services like SQS or Azure Service Bus/Queues, but I'll do my best to point you in the right direction.

问题1。

Question 1.

这将是你做的。最简单的方法是,你可以不-ACK中的RabbitMQ / EasyNetQ一个消息,它会在队列的头放在你重试。这是不是真的不可取的,因为它几乎会立即重试(无时间延迟),也将被处理阻止其他信息(如果你有1预取计数单个用户)。

This will be on you to do. The simplest way is that you can No-Ack a message in RabbitMQ/EasyNetQ, and it will be placed at the head of the queue for you to retry. This is not really advisable because it will be retried almost immediately (With no time delay), and will also block other messages from being processed (If you have a single subscriber with a prefetch count of 1).

我已经看到了使用MessageEnvelope的其他实现。因此,一个包装类,当一个消息失败,则增加对MessageEnvelope重试变量,并且重新提交信息返回到队列中。你必须要做到这一点,写在你的消息处理程序包装代码,它不会是EasyNetQ的函数。

I've seen other implementations of using a "MessageEnvelope". So a wrapper class that when a message fails, you increment a retry variable on the MessageEnvelope and redeliver the message back onto the queue. YOU would have to do this and write the wrapping code around your message handlers, it would not be a function of EasyNetQ.

使用上面,我也看到了人们使用的信封,但允许该消息是死的字母。一旦它在死信队列,还有另外一个应用程序/工人读取来自死信队列项目。

Using the above, I've also seen people use envelopes, but allow the message to be dead lettered. Once it's on the dead letter queue, there is another application/worker reading items from the dead letter queue.

所有这些方法以上的有在一个小问题确实没有任何好的办法有一个数/指数函数/任意种类增加延迟的处理消息。它返回到队列之前,可以抱在一段时间码的消息,但它不是围绕一个很好的方式。

All of these approaches above have a small issue in that there isn't really any nice way to have a logarithmic/exponential/any sort of increasing delay in processing the message. You can "hold" the message in code for some time before returning it to the queue, but it's not a nice way around.

在所有这些选项,自定义的应用程序读取死信队列,决定是否基于包含的重试次数信封路由邮件可能是最好的办法。

Out of all of these options, your own custom application reading the dead letter queue and deciding whether to reroute the message based on an envelope that contains the retry count is probably the best way.

问题2。

Question 2.

您可以指定采用了先进的API每个队列一纸空文交流。 ( https://github.com/EasyNetQ/EasyNetQ/wiki/The-Advanced-API #声明的队列的)。然而,这意味着你将不得不使用先进的API几乎任何地方使用的是简单下iBus落实订阅/发布长相对于基于双方的消息类型和用户名命名的队列中。使用队列的自定义宣告意味着你将要处理你的队列自己的命名,这意味着当你订阅,你需要知道你想要什么等,为你没有更多的自动订阅的名字!

You can specify a dead letter exchange per queue using the advanced API. (https://github.com/EasyNetQ/EasyNetQ/wiki/The-Advanced-API#declaring-queues). However this means you will have to use the advanced API pretty much everywhere as using the simple IBus implementation of subscribe/publish looks for queues that are named based on both the message type and subscriber name. Using a custom declare of queue means you are going to be handling the naming of your queues yourself, which means when you subscribe, you will need to know the name of what you want etc. No more auto subscribing for you!

问题3

Question 3

这是错误队列/死信队列是只是另一个队列。你可以听这个队列中,你需要用它做什么。但没有任何真正的开箱即用解决方案,这听起来像它会满足您的需求。

An Error Queue/Dead Letter Queue is just another queue. You can listen to this queue and do what you need to do with it. But there is not really any out of the box solution that sounds like it would fit your needs.

这篇关于怎么办误差EasyNetQ / RabbitMQ的处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆