如何在MassTransit 3.0中使用分散/聚集模式实现传奇 [英] How to implement a saga using a scatter/Gather pattern In MassTransit 3.0

查看:102
本文介绍了如何在MassTransit 3.0中使用分散/聚集模式实现传奇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Jimmy Boagard在此处 a>将其与分散收集模式进行比较.

Jimmy Boagard describes a McDonalds fast food chain here comparing it to a scatter gather pattern.

从上述文章中窃取的工作流图像:

Workflow image stolen from above article:

初步实施思路:

为所有食品站将获得的所有FoodOrdered事件类型具有一个公共界面,然后每个食品站将能够消费/创建其各自的项目并发布一个公共完成的事件.例如:炸薯条和汉堡站收到有关炸薯条订单的消息,炸薯条站消费该订单,以宣布传奇故事正在侦听的ItemDoneEvent.

To have a common interface for all of the types of FoodOrdered events that all of the food stations would get and then each food station would be able to consume/create its respective item and publish a common done event. Ex: fries and burger station gets a message regarding an order of Fries, The fries station consumes the order announces an ItemDoneEvent that the saga is listening for.

初始问题:

由于Saga并不关心完成的食物的类型,仅考虑所有食物都已完成的事实,因此这似乎是一个 OK 解决方案.但是之后阅读警告此处有关队列共享并注意到

Since the Saga doesn't care about the type of food completed just the fact that all the food is completed this would seem to be an OK solution. However after reading warnings here regarding sharing of queues and noticing that Consumer.Conditional filtering has been removed with MassTransit 3.0 It feels as though the framework is saying "Bad Things(TM) will happen" with this type of approach. But I'm not sure how else you would do it with out creating a message request and response and correlating Event for each food item in the kitchen. Ex: FriesOrdered, BurgerOrdered FriesCooked, BurgerCooked. This would be very tedious if you had to do that for every item in the kitchen?

考虑到上述问题-这种工作流程的一个很好的传奇例子会是什么样?

推荐答案

您不能简单地"将对象作为事件参数传递到队列中吗? 当传奇侦听器收到订单已完成"事件时,它会包含该事件中已完成的对象吗?

Couldn't you "simply" pass the object along in the queue, as an event parameter? When the saga listener gets an "order completed" Event it would contain the object that is completed in the event?

我想象它是通过Generic方法发送到队列的,该对象必须实现IFoodOrdered

I imagine it being sent to the queue via a Generic method, where the object must implement IFoodOrdered

然后,您可以在实现一个虚拟方法时,传奇可以用它来处理通用"事件,而您只需要为那些需要特殊处理的特殊项目实现重载?

Then you can on the implement a virtual method that the saga can use to do the "generic" thing when it's picked up, and you only have to implement overloads for those special items, that require something special to happen?

这篇关于如何在MassTransit 3.0中使用分散/聚集模式实现传奇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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