如何在 NServiceBus 路由中给出另一个解决方案的路由



我正在.net core 2.2应用程序中实现NServiceBus。一切正常,但现在我决定在单独的解决方案中移动处理程序并从 webapi 解决方案调用它们。最初,我在同一解决方案中设置了所有内容,因此我可以像这样实现路由:

var endpointConfiguration = newEndpointConfiguration(AssemblyName);
    var transport = endpointConfiguration.UseTransport<LearningTransport>();
    endpointConfiguration.SendOnly();
    var routing = transport.Routing();
    routing.RouteToEndpoint(
            assembly: typeof(OrderProcessEvent).Assembly,
            destination: "Orders");
    endpoint = NServiceBus.Endpoint.Start(endpointConfiguration).GetAwaiter().GetResult();

现在如何在"目标"中提供其他解决方案的路径?像这样:

 routing.RouteToEndpoint(
        assembly: typeof(OrderProcessEvent).Assembly,
        destination: @"C:EndpointsOrders");

更新:

通过丹尼尔斯的回答。我试过这个:

var endpointConfiguration = new EndpointConfiguration(AssemblyName);
                var transport = endpointConfiguration.UseTransport<LearningTransport>();
                //endpointConfiguration.SendOnly();
                transport.StorageDirectory(@"...Endpoints");
                var routing = transport.Routing();
                routing.RouteToEndpoint(
                    assembly: typeof(OrderProcessEvent).Assembly,
                    destination: "Orders");
                endpoint = NServiceBus.Endpoint.Start(endpointConfiguration).GetAwaiter().GetResult();

但我仍然收到同样的错误

"没有为消息指定目标:命名空间.订单">

使用学习传输(警告不是生产传输(时,可以使用

var transport = endpointConfiguration.UseTransport<LearningTransport>();
transport.StorageDirectory("PathToStoreTransportFiles");

如果所有端点都指向同一目录,则它们可以一起通信。举个简单的例子,假设您的src目录的结构如下

src
  Solution1
  Solution2

您可以按如下所示配置学习传输

var transport = endpointConfiguration.UseTransport<LearningTransport>();
transport.StorageDirectory("...learningtransport");

然后创建

src
  Solution1
  Solution2
  .learningtransport

请注意,如果您像这样设置存储目录,您可能需要考虑到端点将在 bin[Release|Debug]netXYZ 下执行。

有关学习传输配置的详细信息,请参阅 https://docs.particular.net/transports/learning

最新更新