NServiceBus延迟消息处理 [英] NServiceBus Delayed Message Processing
问题描述
我有哪些给定的消息可能不会因处理一些外部事件没有发生的NServiceBus应用程序。因为这个其他事件不是NSB事件我无法实现传奇正确
I have an NServiceBus application for which a given message may not be processed due to some external event not having taken place. Because this other event is not an NSB event I can't implement sagas properly.
然而,不是仅仅重新排队消息(这将导致一个循环,直到该外部事件发生),我在另一个消息(DelayMessage)包装消息和排队的来代替。该DelayMessage由不同服务拾起并且直到重试间隔到期放置在数据库中。在该点,延迟服务重新队列上的原始队列所以另一次尝试可制成消息
However, rather than just re-queuing the message (which would cause a loop until that external event has occurred), I'm wrapping the message in another message (DelayMessage) and queuing that instead. The DelayMessage is picked up by a different service and placed in a database until the retry interval expires. At which point, the delay service re-queues the message on the original queue so another attempt can be made.
然而,这可能发生不止一次如果外部事件仍然没有发生,并且在即使从未发生的情况下,我想限制往返消息需要的数量。这意味着DelayMessage具有MaxRetries属性,但是当服务延迟队列重试原始消息丢失
However, this can happen more than once if that external event still hasn't taken place, and in the case where that even never happens, I want to limit the number of round trips the message takes. This means the DelayMessage has a MaxRetries property, but that is lost when the delay service queues the original message for the retry.
我缺少其他什么选择?我很乐意接受,有一个完全不同的解决这个问题。
What other options am I missing? I'm happy to accept that there's a totally different solution to this problem.
推荐答案
考虑实施的传奇存储,首先消息,抱着它,直到第二个消息到达。您可能还需要以及传奇开超时让您的过程中不会无限期等待如果第二条消息走丢了或什么的。
Consider implementing a saga which stores that first message, holding on to it until the second message arrives. You might also want the saga to open a timeout as well so that your process won't wait indefinitely if that second message got lost or something.
这篇关于NServiceBus延迟消息处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!