NServiceBus Retry Delay

2020-07-11 09:01发布

What is the optimal way to configure/code NServiceBus to delay retrying messages?

In its default configuration retry happens almost immediately up to the number of attempts defined in the configuration file. I'd ideally like to retry again after an hour, etc.

Also, how does HandleCurrentMessageLater() work? What does the Later aspect refer to?

标签: nservicebus
3条回答
Emotional °昔
2楼-- · 2020-07-11 09:21

The NSB retries is there to remedy temporary problems like deadlocks etc. Longer retries is better handled by creating another process that monitors the error queue and puts them back into to the source queue at the interval you like. Take a look at the ReturnToSourceQueue.exe that comes with NSB for reference.

Edit: NServiceBus now supports this , we call it Second Level Retries, see http://docs.particular.net/ for more details

查看更多
狗以群分
3楼-- · 2020-07-11 09:31

Here is a blog post on why NServiceBus doesn't include a retry delay that I wrote after asking Udi this very same question in his distributed systems architecture course:

NServiceBus Retries: Why no back-off delay?

And here is a discussion thread covering some of the points involved in building an error queue monitor/retry endpoint:

http://tech.groups.yahoo.com/group/nservicebus/message/10964

As far as HandleCurrentMessageLater(), all that does is puts the current message back at the end of the queue. If there are no other messages waiting, it's going to be processed again immediately.

查看更多
对你真心纯属浪费
4楼-- · 2020-07-11 09:38

As of NServiceBus 3.2.1, they provide an out of the box solution to handle back off delays in the event of consecutive message failures. The previously existing retry mechanism still retries failures without a delay to handle cases like Database deadlocks, quickly self healing network issues, etc.

Once a message has been retried the configured number of times, the message is moved to a "Second Level Retry" queue. This queue, as configured below, will retry after a 10, 20, and 30 second delay, then the message will be moved to the configured error queue. You're free to change these values to something that better suites your environment.

You can also check out this link: http://docs.particular.net/nservicebus/second-level-retries

查看更多
登录 后发表回答