如何nservicebus处理信息的订单? [英] How to handle message order in nservicebus?

查看:107
本文介绍了如何nservicebus处理信息的订单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到一种方式来处理,他们从发送者被送往因为NServiceBus并不能保证邮件将在一个特定的顺序来处理订单的消息。

I'm trying to find a way to process messages in the order they were sent from the sender since NServiceBus does not guarantee that messages will be processed in a particular order.

发送方是一个订单系统,发布createOrder和reviseOrder命令。发件人允许多个版本提交到相同的顺序,以便可以有修订4和修订3在队列的同时该用户。每个版本都有一个与之关联的版本号和理性code驱动一些业务逻辑,所以我们不能忽视任何修订或至少部分原因吧。

The sender is an order system which publishes createOrder and reviseOrder commands. The sender allows the user to submit multiple revisions to the same order so there can be revision 4 and revision 3 in the queue at the same time. Each revision has a revision number and reason code associated with it which drives some business logic so we cannot ignore any revisions or at least the reason part of it.

一对夫妇的想法我有如下: -

A couple of ideas I had are listed below -

  1. 存储与目的地记录中的版本号。发送方发送自己的版本号在每个版本的消息。该处理程序比较发送方和目的地版本号,如果它们匹配的记录被其他更新将消息放置在队列的末尾。通过这种方法,如果版本2的消息失败,进入错误队列版本3将不会被处理。

  1. Store the revision number with the destination record. The sender sends their revision number in each revision message. The handler compares the sender and destination revision numbers, if they match the record is updated else the message is put at the end of the queue. With this approach if revision 2 message fails and goes into the error queue revision 3 will never be processed.

发件人发送的所有原因,codeS的历史上的每一个版本,消息的所有版本。因此,如果修订2消息失败,第三次修订版的消息将所有的原因,codeS。这些原因codeS将被记录在了目的地,但是与previous修订原因code相关的任何业务逻辑可能不会发生。

Sender sends the history of all reason codes for all revisions on every revision message. So if revision 2 message fails, revision 3 message will have all the reason codes. These reason codes will be recorded in the destination but any business logic associated with the previous revisions reason code may not occur.

如何设计这个场景?
如何处理失败的修订信息又什么想法?

How do we design for this scenario?
Also any ideas on how to handle the failed revision messages?

一些指导,真是AP preciated。

Some guidance is really appreciated.

感谢。

推荐答案

开箱各地NserviceBus的主要指导方针之一是,你应该按照这个顺序并不重要的方式建立自己的系统。说了这么多我已经与NSB一个有序的系统之前,我继承人决定如何做到这一点:

Out of the box one of the primary guidelines around NserviceBus is that you should build your systems in a way that order doesnt matter. Having said that i have built an ordered system with NSB before, heres how I decided to do it:

  • 添加序列号的所有邮件
  • 在接收方检查序列号是最后一次露面号+ 1如果不是抛出一个失序异常
  • 启用第二级重试(这样,如果他们不按顺序,他们将再次尝试在接收到正确的信息后,以后希望)

这通常工作pretty的很好,但是有时候东西会有点不正常了,如果事情是不按顺序太久,人工干预重新排序是必需的。

This generally works pretty well, however sometimes stuff will go a bit out of whack if something is out of order for too long and manual intervention to resequence is required.

在你的情况有可能是一个更好的办法。鉴于你只是想这都是为了令的修订版中的排序。我觉得你可以在不需要有序传递的方式建立这一点。

In your scenario there is probably a better way. Given you are only wanting ordering within the revisions which are made to orders. I think you can build this in a way that doesn't require ordered delivery.

  • 添加一个修订版本,所有这一切,你可以用修改
  • 修改字段
  • 仅更新字段,如果该消息中的版本号为> =在db

这有一堆的好处。

  • 在它不依赖于订单
  • 在它只要求接收方处理每封邮件一次降低负荷
  • 在它处理pretty的以及有错误通过不停止一切,如果有一个问题,一个消息。

但它有以下缺点:

  • 添加在db
  • 的复杂性
  • 在其最终一致的,如果你的数据库可能只包含了一些修改用户已经完成了。
  • 如果转2的错误和REV3正确地处理一些用户的编辑不会在那里,但有些则

这篇关于如何nservicebus处理信息的订单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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