ASP.NET MVC 异步控制器和 Active MQ
场景:用户保存订单
完成订单工作流程需要做的事情:
- 将订单保存到数据库,并带有“未确认”标志。
- 将订单推送到 Active MQ 并监听出现在另一个 Q 中的确认消息。通常需要 1 分钟到未知时间才能在另一个 Q 中接收确认消息。
- 当我在数据库中收到确认更新标志时。
我不希望用户等到收到确认消息,因此一旦订单成功保存到数据库,用户就可以离开网页。目前,我正在使用 Ajax post 方法将订单保存到数据库,并计划在保存到数据库成功时调用异步操作。此异步操作假定与 Active MQ 一起使用,并无限期地等待,直到收到确认。
问题:异步控制器是正确的选择吗?或者我应该编写一个 Windows 服务来轮询确认 Q 并相应地更新数据库。主要目标是降低复杂性和维护开销。
Scenario: User saves an Order
Things need to be done to complete Order workflow:
- Save order to Database with a flag 'not acknowledged'.
- Push order to Active MQ and listen for acknowledgement message due to appear in another Q. Usually it takes from 1 minutes to unknown time to receive acknowledgement message in the other Q.
- When I receive acknowledgement update flag in Database.
I don't want user to wait until acknowledgement message received, so once Order saved successfully to the database user can navigate away from the web page. Currently I'm saving orders to Database using an Ajax post method and planning to call an Async action when saving to Database is successful. This Async action is suppose to work with Active MQ and wait indefinitely till it receive an acknowledgement.
Question: Is Async controllers is the right choice here? Or shall I write a Windows services which polls for the acknowledgement Q and update Database accordingly. Main objective to reduce complexity and maintenance overhead.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论