NService 总线消息未按顺序传入(即发送时)

发布于 2024-09-03 05:16:35 字数 87 浏览 3 评论 0原文

我们使用 NService 总线作为我们的消息传递框架。有时消息不会按照发送顺序发送。有时最后一条消息先到达,然后比第一条消息晚。

请帮帮我谢谢

We are using NService bus for our messaging framework.Sometime the message is not coming as par the sequence of sending .Sometimes last message is coming first and than later first message.

Please help me out Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

那支青花 2024-09-10 05:16:35

NServiceBus 的性质不保证消息将按照发送的顺序接收。每条消息都应该被独立处理。

如果只有在两条相关消息到达后才能执行某项操作,那么您需要使用 Saga

编辑第一条评论:

您提到您正在分块发送相同的消息。这是否意味着您有一个很大的有效负载,必须将其分成多个部分才能通过 MSMQ 传输?

如果是这样,您有几个选择:

  1. 将有效负载存储在带外数据库或文件系统中,并且仅将足够的数据放入一条消息(ID 或文件系统路径)中以从消息处理程序加载数据.

  2. 使消息成为包含 BundleID、PartNumber、TotalParts 和 PayloadChunk 的 MessagePart。然后,为 MessagePart 创建一个传奇来存储每个部分,当收到所有部分时,将块重新组合在一起并执行您需要的操作。当然,如果您需要将生成的大对象发送回总线,这很快就会变得烦人,因此带外选项看起来会更有吸引力。

无论如何,有很多原因导致任何 MSMQ 消息(而不仅仅是 NServiceBus 消息)可能无序到达,因此您必须能够处理它。

The nature of NServiceBus does not guarantee that messages will be received in the order they were sent. Each message is meant to be processed independently.

If an action can only be undertaken after two related messages arrive, then you need to utilize a Saga

Edit in response to first comment:

You mention you're sending the same message in chunks. Does this mean that you have a large payload that you have to split up into multiple parts to transmit via MSMQ?

If so, you have a few options:

  1. Store the payload out of band, in a database or file system, and only put enough data in one message (an ID or file system path) to load the data from the message handler.

  2. Make the message a MessagePart that contains a BundleID, PartNumber, TotalParts, and PayloadChunk. Then, create a saga for MessagePart that stores each part and when all parts have been received, reconstitute the chunks together and do what you need. Of course, if you need to then send the resulting large object back onto the Bus, this would get annoying really quickly, so then the out-of-band option would look much more attractive.

In any case, there are a ton of reasons why any MSMQ message, not just NServiceBus messages, could arrive out of order, so you have to be able to deal with it.

心在旅行 2024-09-10 05:16:35

Bus.Sending 一组消息可以工作吗? NServiceBus 允许批量消息

Would Bus.Sending a collection of Imessages work? NServiceBus allows batching of messages

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文