NServiceBus:按需处理消息

发布于 2024-11-15 14:56:53 字数 572 浏览 2 评论 0原文

我刚刚接触服务总线(特别是 NServiceBus),并且刚刚编写了我的第一个 Saga。

该传奇旨在接收交易,然后发送消息以针对大多数封闭的系统(难以以编程方式访问)验证用户 ID、付款详细信息和产品详细信息等。现在,某些功能很容易实现自动化并为其编写处理程序,但在某些情况下需要手动干预才能完成事务,因为没有可用的 API 来执行这些任务。现在我们将有多个人工代理来解决这个问题,因此并发性是一个问题,我想为什么不让每个用户按需提取下一条消息,从而利用 MSMQ 固有的并发性。

我无法在 nhibernate 上的 IBus 上找到任何方法来允许按需检索下一条可用消息,因为看起来一切都是基于推送的。因此,我设计了一个 UI 原型,它使用标准 .NET System.Messaging.MessageQueue API 手动从 MSMQ 检索消息,并允许用户与之交互,然后通过 IBus 写回响应,将返回结果发送回 saga。发送()方法。

我对此的主要问题是:这是否违反了 NServiceBus 的基本原则?如果没有,是否可以通过 NServiceBus API 来执行此操作?

您还会通过 MSMQ 或 UI 应用程序处理并发吗?

干杯

I am just new to service busses (in particular NServiceBus) and have just written my first Saga.

The saga is intended to recieve a transaction and then send messages off to validate the users id, payment details, and product details, etc. against a mostly closed system (difficult to access programatically). now some of the functionality is easy to automate and write handlers for, but there are a few cases where manual intervention is required to complete the transaction as there is no api available to perform these tasks. Now we are going to have multiple human agents working against this so concurrency is an issue, and I thought why not have each user pull the next message on demand, and so utilise the concurrency inherent in MSMQ.

I haven't been able to find any methods on the IBus on nhibernate to allow for retrieving the next available message on demand as it appears everything is push based. So I have prototyped a a UI that manually retrieves the messages from MSMQ using the standard .NET System.Messaging.MessageQueue API and allows the user to interact with this and then send the return back to the saga by writing the response back via the IBus.Send() method.

My main question in regards to this is: Does this break the fundemental principles around NServiceBus? and if not is there anyway to do this through the NServiceBus API?

Also would you handle the concurrency through the MSMQ or through the UI application?

Cheers

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

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

发布评论

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

评论(1

很酷不放纵 2024-11-22 14:56:53

由于各种原因,NSB 中的所有内容都是单向的。为了通知您的客户他们需要做一些事情,您可以轮询视图模型以查看在某个时间间隔内是否有工作要做。 Saga 将负责插入/更新正确的行以供 UI 识别。 UI 完成后,您可以使用 NSB 将消息 Send() 发送回 Saga。如果这是一个 Web UI,请查看下载中的 AsyncPages 示例。

另一种方法是将消息推送到客户端,假设消息传递与客户端一起安装。您将需要在后台创建某种消息泵。同样,一旦工作完成,一个简单的 Send() 就可以了。

Everything in NSB is unidirectional on purpose for a whole host of reasons. In order to notify your clients that they need to do something you could poll a view model to see if there is work to be done on some interval. The Saga would be responsible for inserting/updating the right rows for the UI to pick up on. Once the UI is complete you can use NSB to Send() a message back to the Saga. If this is a web UI, check out the AsyncPages sample in the download.

Another way to do this would be to push a message to the client, assuming that messaging is installed along with the client. You will need to create some kind of message pump in the background. Again, once work is complete, a simple Send() will do.

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