NServiceBus 消息重播存档架构
我正在构建一个应用程序,需要保留其发送的消息的副本,以便我可以在稍后阶段重播所有消息。这是必要的,因为消息的处理在开发过程中会发生巨大变化,但数据必须尽快捕获,因为它是实时观察数据。我似乎找不到任何内置功能可以直接解决这个问题,虽然我可以编写一个自定义工具来保存数据,但这似乎与首先使用 NServiceBus 的目的相矛盾。我正在考虑的一些选项:
使用目标总线的 ForwardReceivedMessagesTo 功能来创建存档队列,并构建一个简单的应用程序,该应用程序使用此存档队列作为输入队列,以便在重播工具运行时将消息简单地转发到目标总线运行。这确实会清除存档队列,要求首先使用 mqbkup 实用程序对其进行备份,但这可以作为重播过程的一部分自动进行。或者,使用两个交替的存档队列(一个接收新消息,一个用于重播)可以解决此问题。
使用发布/订阅模型并让存档器订阅目标队列,将消息放入存档队列中。与上述类似的 Replayer 工具可以使用 Archive 队列作为输入队列,并将消息转发到 Target。这也会清除存档队列,需要上述解决方案之一。
MassTransit 人员提到了一个名为 BusDriver 的东西,它允许在之间进行复制排队,但我找不到更多相关信息。
我主要关心的是选择最不可能丢失数据的方法,因为一旦进行观察,就不可能在狭窄的时间窗口之外再次进行观察。这似乎应该是一个常见问题,但我似乎无法找到直接的解决方案。建议?
更新 我决定使用日志目标队列。我将让归档器使用日志作为输入并将消息存储到数据库(可以只是基于文件),并允许将消息从该数据库重播到目标队列。虽然可以编写一个工具将消息从日志队列复制到目标队列,但从实际角度来看,真正的问题是管理日志队列:它无法轻松备份(mqbkup 会导致日志队列崩溃) MSMQ 服务,这是不可接受的),并且当我宁愿坚持 NServiceBus 抽象级别时,在队列上进行非破坏性操作需要我编写一个基于 MSMQ 的工具。最终,MSMQ 是一种传输而不是消息存储,因此需要将其视为消息存储。
I'm building an application that needs to preserve copies of the messages it is sending so that I can replay all the messages at a later stage. This is necessary because the processing of the messages will change dramatically over the course of development, but the data must be captured ASAP since it is realtime observation data. I can't seem to find any built-in functionality that directly addresses this and while I could write a custom tool to persist the data, that seems to contradict the purpose of using NServiceBus in the first place. Some options I'm considering:
Use the ForwardReceivedMessagesTo functionality of the Target bus to create an Archive queue, and build a simple application which uses this Archive queue as an input queue for simply forwarding messages onto the Target bus whenever the Replayer tool runs. This does clear the Archive queue, requiring it to be backed up first using the mqbkup utility, but this can be automated as part of the replay process. Alternatively, using two alternating Archive queues (one taking in new messages, and one for replaying) would solve this.
Use a publish/subscribe model and have an Archiver subscribe to the Target queue, placing the message in an Archive queue. A Replayer tool similar to the one above could use the Archive queue as an input queue and forward the messages to the Target. This would also clear the Archive queue, requiring one of the solutions above.
MassTransit people mention something called BusDriver that allows copying between queues but I can't find anything more about it.
My primary concern is to choose the approach that is least likely to lose data as once an observation is made it can never be made again outside of a narrow time window. This seems like it should be a common problem and yet I can't seem to find a straightforward solution to it. Suggestions?
Update I've decided to go with a journalled Target queue. I'll have an Archiver use the journal as an input and store messages to a database (could just be file-based), as well as allow for replaying messages from that database to the Target queue. While it would be possible to write a tool that copies messages from the journal queue to the target queue, the real problem - from a practical perspective - is that of managing the journal queue: it can't be backed up easily (mqbkup brings down the MSMQ service, which is unacceptable), and operating non-destructively on the queue requires me to write an MSMQ-based tool when I'd rather stick to the NServiceBus level of abstraction. Ultimately, MSMQ is a transport and not a store of messages so it needs to be treated as such.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
第一个选择似乎可行。我想补充一点,NSB 附带了一个名为 ReturnToSourceQueue.exe 的工具,它将为您重播消息。您可以打开日记功能来保留消息,但由于它不滚动,因此必须进行清理。我们有 NetApp,并且使用其 SnapMirror 来备份队列数据,我确信也有类似的东西。
The first option seems viable. I would add that NSB comes with a tool named ReturnToSourceQueue.exe that will replay messages for you. You could turn on journalling to keep messages, but something would have to clean that up since it doesn't roll. We have NetApp and we've used its SnapMirror to backup queue data, I'm sure there are similar things out there.
#3 BusDriver 命令行参考:
#3 BusDriver command-line reference: