简体   繁体   English

NService Bus-基于内容的路由和审核-我的方法可以吗?

[英]NService Bus - Content based routing & auditing - is my approach ok?

I have a little trouble deciding which way to go for while designing the message flow in our system. 在设计系统中的消息流时,我很难确定要走的路。

Because the volatile nature of our business processes (ie calculating freight costs) we use a workflow framework to be able to change the process on the fly. 由于业务流程的易变性(即计算运费),我们使用工作流框架来即时更改流程。

The general process should look something like this 一般过程应如下所示 工作流程处理过程
The interface is a service which connects to the customers system via whatever interface the customer provides (webservices, tcp endpoints, database polling, files, you name it). 该接口是一项服务,可通过客户提供的任何接口(webservices,tcp终结点,数据库轮询,文件,您自行命名)连接到客户系统。 Then a command is sent to the executor containing the received data and the id of the workflow to be executed. 然后,将包含接收到的数据和要执行的工作流程的ID的命令发送到执行器。

The first problem comes at the point where we want to distribute load on multiple worker services. 第一个问题出现在我们要在多个工作程序服务上分配负载的时候。
Say we have different processes like printing parcel labels, calculating prices, sending notification mails. 假设我们有不同的流程,例如打印包裹标签,计算价格,发送通知邮件。 Printing the labels should never be delayed because a ton of mailing workflows is executed. 标签的打印绝不应该被延迟,因为要执行大量的邮件工作流程。 So we want to be able to route commands to different workers based on the work they do. 因此,我们希望能够根据他们所做的工作将命令路由到不同的工作人员。

Because all commands are like "execute workflow XY" we would be required to implement our own content based routing. 因为所有命令都类似于“执行工作流程XY”,所以我们将需要实施自己的基于内容的路由。 NServicebus does not support this out of the box, most times because it's an anti pattern. NServicebus多数情况下都不支持此功能,因为它是一种反模式。

Is there a better way to do this, when you are not able to use different message types to route your messages? 当您无法使用其他消息类型来路由消息时,是否有更好的方法来做到这一点?

The second problem comes when we want to add a monitoring. 当我们要添加监视时,出现第二个问题 Because an endpoint can only subscribe to one queue for each message type we can not let all executors just publish a "I completed a workflow" message. 因为端点只能为每种消息类型预订一个队列,所以我们不能让所有执行者仅发布“我完成了工作流程”消息。 The current solution would be to Bus.Send the message to a pre configured auditing endpoint. 当前的解决方案是将Bus.Send发送给预先配置的审核端点。 This feels a little like cheating to me ;) 这感觉有点像欺骗我;)

Is there a better way to consolidate published messages of multiple workers into one queue again? 是否有更好的方法将多个工作人员的已发布消息再次合并到一个队列中? If there would not be problem #1 I think all workers could use the same input queue however this is not possible in this scenario. 如果没有问题#1,我认为所有工作人员都可以使用相同的输入队列,但是在这种情况下是不可能的。

You can try to make your routing not content-based, but headers-based which should be much easier. 您可以尝试使路由不是基于内容的路由,而是基于标头的路由,这应该容易得多。 You are not interested if the workflow is to print labels or not, you are interested in whether this command is priority or not. 您对工作流是否要打印标签不感兴趣,对此命令是否优先级不感兴趣。 So you can probably add this information into the message header... 因此,您可以将此信息添加到消息标题中...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM