NServiceBus - 发布后回复消息

发布于 2024-10-10 06:46:02 字数 910 浏览 2 评论 0原文

我有一个成功处理消息的订阅者,然后订阅者继续成功发布另一条消息以表明某个事件已经发生,我的问题是我在发布后尝试将消息返回给初始消息的发送者,并且系统失败并显示以下消息

没有为消息 NServiceBus.Unicast.Transport.CompletionMessage 指定目的地。无法发送消息。检查配置文件中的 UnicastBusConfig 部分,并确保该消息类型存在 MessageEndpointMapping。

返回代码如下所示:

 Bus.Publish(orderMessage);

 Bus.Return((int)MySendBus.Core.ErrorCode.Ok);

app.config 如下:

<configuration>
  <configSections>
    <section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core"/>
  </configSections>

  <MsmqTransportConfig InputQueue="MyServerInputQueue" ErrorQueue="error" NumberOfWorkerThreads="1" MaxRetries="5"/>
</configuration>

我添加了单播部分,但仍然收到相同的错误。我的理解是,NServicebus 知道如何回复消息,除了 app.config 中找到的 MsmqTransportConfig 输入队列之外,我不必指定一个队列来继续回复。

是否可以让订阅者发布消息然后响应消息发送的位置?

I have a subscriber that successfully handles a message, the subscriber then proceeds to successfully publish another message to state that a certain event has happened, my problem is that i after the publish i attempt to return a message to the sender of the initial message and the system fails with the following message

No destination specified for message NServiceBus.Unicast.Transport.CompletionMessage. Message cannot be sent. Check the UnicastBusConfig section in your config file and ensure that a MessageEndpointMapping exists for the message type.

The return code looks as follows:

 Bus.Publish(orderMessage);

 Bus.Return((int)MySendBus.Core.ErrorCode.Ok);

and the app.config is as follows:

<configuration>
  <configSections>
    <section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core"/>
  </configSections>

  <MsmqTransportConfig InputQueue="MyServerInputQueue" ErrorQueue="error" NumberOfWorkerThreads="1" MaxRetries="5"/>
</configuration>

I've added a unicast section and still get the same error. My understanding is that NServicebus knows how to reply to the message and i shouldn't have to specify a queue for the reply to go on other than the MsmqTransportConfig input queue found in the app.config.

Is it possible to have a subscriber publish a message then respond to the where the message was sent?

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

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

发布评论

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

评论(1

云仙小弟 2024-10-17 06:46:02

如果您使用 Bus.Return(),则必须在客户端端点上注册回调,如下所示:

Bus.Send<IRequestDataMessage>(m =>
            {
                m.DataId = g;
                m.String = "<node>it's my \"node\" & i like it<node>";
            })
                .Register(i => Console.Out.WriteLine(
                                   "Response with header 'Test' = {0}, 1 = {1}, 2 = {2}.",
                                   Bus.CurrentMessageContext.Headers["Test"],
                                   Bus.CurrentMessageContext.Headers["1"],
                                   Bus.CurrentMessageContext.Headers["2"]));

如果您想返回您选择的完整消息,则使用 Bus.Reply() 并在客户端端点中编写处理程序。我的完整示例可以在此处找到。

If you use Bus.Return() then you must register a call back on the client endpoint like so:

Bus.Send<IRequestDataMessage>(m =>
            {
                m.DataId = g;
                m.String = "<node>it's my \"node\" & i like it<node>";
            })
                .Register(i => Console.Out.WriteLine(
                                   "Response with header 'Test' = {0}, 1 = {1}, 2 = {2}.",
                                   Bus.CurrentMessageContext.Headers["Test"],
                                   Bus.CurrentMessageContext.Headers["1"],
                                   Bus.CurrentMessageContext.Headers["2"]));

If you want to return a full message of your choosing then use Bus.Reply() and write a handler in your client endpoint. My full sample can be found here.

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