NServiceBus 消息重播存档架构

发布于 2024-10-22 03:12:17 字数 1100 浏览 2 评论 0原文

我正在构建一个应用程序,需要保留其发送的消息的副本,以便我可以在稍后阶段重播所有消息。这是必要的,因为消息的处理在开发过程中会发生巨大变化,但数据必须尽快捕获,因为它是实时观察数据。我似乎找不到任何内置功能可以直接解决这个问题,虽然我可以编写一个自定义工具来保存数据,但这似乎与首先使用 NServiceBus 的目的相矛盾。我正在考虑的一些选项:

  1. 使用目标总线的 ForwardReceivedMessagesTo 功能来创建存档队列,并构建一个简单的应用程序,该应用程序使用此存档队列作为输入队列,以便在重播工具运行时将消息简单地转发到目标总线运行。这确实会清除存档队列,要求首先使用 mqbkup 实用程序对其进行备份,但这可以作为重播过程的一部分自动进行。或者,使用两个交替的存档队列(一个接收新消息,一个用于重播)可以解决此问题。

  2. 使用发布/订阅模型并让存档器订阅目标队列,将消息放入存档队列中。与上述类似的 Replayer 工具可以使用 Archive 队列作为输入队列,并将消息转发到 Target。这也会清除存档队列,需要上述解决方案之一。

  3. 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:

  1. 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.

  2. 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.

  3. 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 技术交流群。

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

发布评论

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

评论(2

甲如呢乙后呢 2024-10-29 03:12:17

第一个选择似乎可行。我想补充一点,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.

纵性 2024-10-29 03:12:17

#3 BusDriver 命令行参考:

BusDriver is a command-line utility used to administer queues, service bus instances and other things related to MassTransit.

Command-Line Reference

  busdriver.exe [verb] [-option:value] [--switch]

    help, --help        Displays help

    count               Counts the number of messages in the specified
                        queue

      -uri              The URI of the queue

    peek                Displays the body of messages in the queue without
                        removing the messages

      -uri              The URI of the queue
      -count            The number of messages to display

    move                Move messages from one queue to another

      -from             The URI of the source queue
      -to               The URI of the destination queue
      -count            The number of messages to move

    requeue             Requeue messages from one queue to another

      -uri              The URI of the queue
      -count            The number of messages to move

    save                Save messages from a queue to a set of files

      -uri              The URI of the source queue
      -file             The name of the file to write to (will have .1, .2
                        appended automatically for each message)
      -count            The number of messages to save
      --remove          If set, the messages will be removed from the queue

    load                Load messages from a set of files into a queue

      -uri              The URI of the destination queue
      -file             The name of the file to read from (will have .1, .2
                        appended automatically for each message)
      -count            The number of messages to load
      --remove          If set, the message file will be removed once the
                        message has been loaded

    trace               Request a trace of messages that have been received
                        by a service bus

      -uri              The URI of the control bus for the service bus
                        instance
      -count            The number of messages to request

        status          Request a status probe of the bus at the endpoint

          -uri          The URI of the control bus for the service bus instance

    exit, quit          Exit the interactive console (run without arguments
                        to start the interactive console)

Examples:

    count -uri:msmq://localhost/mt_server
        Returns the number of messages that are present in the local
        MSMQ private queue named "mt_server"

    peek -uri:msmq://localhost/mt_client
        Displays the body of the first message present in the local
        MSMQ private queue named "mt_client"

    trace -uri:msmq://localhost/mt_subscriptions
        Requests and displays a trace of the last 100 messages received
        by the mt_subscriptions (the default queue name used by the
        subscription service, which is part of the RuntimeServices)

    move -from:msmq://localhost/mt_server_error -to:msmq://localhost/mt_server
        Moves one message from the mt_server_error queue to the mt_server
        queue (typically done to reprocess a message that was previously
        moved to the error queue due to a processing error, etc.)

#3 BusDriver command-line reference:

BusDriver is a command-line utility used to administer queues, service bus instances and other things related to MassTransit.

Command-Line Reference

  busdriver.exe [verb] [-option:value] [--switch]

    help, --help        Displays help

    count               Counts the number of messages in the specified
                        queue

      -uri              The URI of the queue

    peek                Displays the body of messages in the queue without
                        removing the messages

      -uri              The URI of the queue
      -count            The number of messages to display

    move                Move messages from one queue to another

      -from             The URI of the source queue
      -to               The URI of the destination queue
      -count            The number of messages to move

    requeue             Requeue messages from one queue to another

      -uri              The URI of the queue
      -count            The number of messages to move

    save                Save messages from a queue to a set of files

      -uri              The URI of the source queue
      -file             The name of the file to write to (will have .1, .2
                        appended automatically for each message)
      -count            The number of messages to save
      --remove          If set, the messages will be removed from the queue

    load                Load messages from a set of files into a queue

      -uri              The URI of the destination queue
      -file             The name of the file to read from (will have .1, .2
                        appended automatically for each message)
      -count            The number of messages to load
      --remove          If set, the message file will be removed once the
                        message has been loaded

    trace               Request a trace of messages that have been received
                        by a service bus

      -uri              The URI of the control bus for the service bus
                        instance
      -count            The number of messages to request

        status          Request a status probe of the bus at the endpoint

          -uri          The URI of the control bus for the service bus instance

    exit, quit          Exit the interactive console (run without arguments
                        to start the interactive console)

Examples:

    count -uri:msmq://localhost/mt_server
        Returns the number of messages that are present in the local
        MSMQ private queue named "mt_server"

    peek -uri:msmq://localhost/mt_client
        Displays the body of the first message present in the local
        MSMQ private queue named "mt_client"

    trace -uri:msmq://localhost/mt_subscriptions
        Requests and displays a trace of the last 100 messages received
        by the mt_subscriptions (the default queue name used by the
        subscription service, which is part of the RuntimeServices)

    move -from:msmq://localhost/mt_server_error -to:msmq://localhost/mt_server
        Moves one message from the mt_server_error queue to the mt_server
        queue (typically done to reprocess a message that was previously
        moved to the error queue due to a processing error, etc.)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文