【问题标题】:Using several NServicebus endpoints使用多个 NServicebus 端点
【发布时间】:2017-03-10 19:38:30
【问题描述】:

我正在尝试托管 NServicebus 的 2 个端点,指向 2 个不同的队列并将消息发送到这 2 个队列。 出于某种奇怪的原因,它不起作用。 我用谷歌搜索,在某些地方人们说这是可能的,在其他地方:不可能。

这是我的代码,适用于单个端点:

//Here I configure the endpoint
var endpointConfiguration = new EndpointConfiguration(endpointName: Queue1);

endpointConfiguration.SendFailedMessagesTo("error");
endpointConfiguration.UseSerialization<JsonSerializer>();

endpointConfiguration.EnableInstallers();

endpointConfiguration.UsePersistence<InMemoryPersistence>();

_endpointInstance = await Endpoint.Start(endpointConfiguration).ConfigureAwait(false);
//Here I send a command
_endpointInstance.Send(Queue1, command);

但是如果我使用新端点的另一个变量复制粘贴此代码,例如 _endpointInstance2(意味着:我使用相同的代码来实例化新端点),应用程序就会崩溃

【问题讨论】:

  • 请发布您尝试做的完整代码。
  • 你应该也在等待发送.. :)

标签: c# messaging nservicebus


【解决方案1】:

在 v4 及之前的版本中,您不能在一个 AppDomain 中托管多个端点。这在 v5 及之后的版本中得到了纠正。文档网站上的 This sample 准确显示了您正在寻找的内容。

只需考虑两件事:确保您使用的是正确的版本(您似乎使用的是 v6,这很好)并且不要重复使用配置对象。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-13
    • 2013-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-13
    • 1970-01-01
    相关资源
    最近更新 更多