与 NServiceBus 合并的应用程序的预定执行
我想让一个应用程序每天运行一次,当它启动时,它必须从它订阅的队列中读取所有消息,进行一些处理,发布消息然后关闭。消息已通过 NServiceBus 发送,您如何知道它们何时已全部处理完毕?我不知道如何处理队列中的所有消息并告诉队列何时为空。
I want to have an application run once a day and when it starts, it must read all the messages from the queue it subscribes to, do some processing, publish a message and then close. The messages have been sent via NServiceBus, how do you tell when they've all been processed? I can't figure out how to process all the messages in the queue and tell when the queue it is empty.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这听起来像是一个架构问题,而不是 NSertviceBus 特定的问题。
这就是我用 NSB 解决这个问题的方法:
我会让我的端点(订阅者)实现 Quartz .Net 并安排时间将发送指示 StartOfBusinessDay(每天)的命令/消息的作业。
我将有一个 Saga,从 StartOfBusinessDay 开始,当 Saga 初始化时,我会请求 T+ 的超时(到工作日结束的小时数)。
这个 Saga 将不断接收消息并聚合它们以供稍后处理。
当超时发生时,处理所有聚合消息并发布 ProcessCompletedEvent 以通知任何其他订阅者当天结束批次已完成,然后是当天的 MarkSagaCompleted。
希望这有帮助。
It sounds like its an architectural question, rather than NSertviceBus specific.
This is how I would solve it with NSB:
I would have my endpoint (subscriber) implement Quartz .Net and schedule a job that will send a command/message indicating the StartOfBusinessDay (every day).
I would have a Saga, start by the StartOfBusinessDay and when the saga is initialized, I would request a TimeOut of T+(hours to end of business day).
This Saga will continually receive messages and aggregate them for processing later.
When your TimeOut occurs, Process all aggregated messages and publish ProcessCompletedEvent to notify any other subscribers that the end of day batch is completed, then MarkSagaCompleted for that day.
Hope this helps.