我可以通过并处理相同的消息来启动 NserviceBus 传奇吗? [英] Can I have a NserviceBus saga be started by AND handle the same message?
问题描述
快速问题:我有一个传奇,它可以有一个场景,它需要处理可能在两种情况下出现的消息.一种是传奇仍处于打开状态,另一种是传奇已被标记为完成.
Quick question: I have a saga that can have a scenario where it needs to handle a message that could come in under two situations. One where the saga is still open and one where the saga has been marked as complete.
如果传奇是开放的,太好了,照常继续.如果传奇没有打开,它需要开始一个新的传奇.处理这种情况的最佳做法是什么?IHandleMessages<>
效果很好,显然,如果传奇是开放的.但是 IAmStartedByMessages<>
不会导致两个传奇打开吗?这会很糟糕.谢谢
If the saga is open, great, continue as normal. If the saga is not open it needs to to start a new saga. What is the best practice to handle this situation? IHandleMessages<>
works great, obviously, if the saga is open. But won't IAmStartedByMessages<>
cause two sagas to be open? This would be bad. Thanks
推荐答案
IAmStartedByMessages<>
如果可以解决已打开的 saga,则不会导致打开 2 个 saga.您应该可以只使用 IAmStartedByMessages<>
而无需 IHandleMessages<>
.
IAmStartedByMessages<>
will not cause 2 sagas to be open if an already open saga can be resolved. You should be fine to just use IAmStartedByMessages<>
with no need for an IHandleMessages<>
.
这篇关于我可以通过并处理相同的消息来启动 NserviceBus 传奇吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!