NServiceBus 延迟消息处理
我有一个 NServiceBus 应用程序,由于某些外部事件尚未发生,可能无法处理给定的消息。因为这个其他事件不是 NSB 事件,所以我无法正确实现传奇。
但是,我不是只是重新排队消息(这会导致循环,直到外部事件发生),而是将消息包装在另一条消息 (DelayMessage) 中并将其排队。 DelayMessage 由不同的服务拾取并放置在数据库中,直到重试间隔到期。此时,延迟服务会在原始队列上重新排队消息,以便可以进行另一次尝试。
但是,如果该外部事件仍未发生,则这种情况可能会发生多次,并且在这种情况从未发生的情况下,我想限制消息的往返次数。这意味着 DelayMessage 具有 MaxRetries 属性,但当延迟服务将原始消息排队以进行重试时,该属性就会丢失。
我还缺少哪些其他选择?我很高兴接受这个问题有一个完全不同的解决方案。
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.
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.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
考虑实现一个 saga 来存储第一条消息,并保留它直到第二条消息到达。您可能还希望 saga 也打开一个超时,以便您的进程不会'如果第二条消息丢失或发生其他情况,请不要无限期地等待。
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.