我的 NServiceBus 得到了这个配置:
builder.Host.UseNServiceBus(ctx =>
{
var endpointConfiguration = new EndpointConfiguration("my.orders");
var transport = endpointConfiguration.UseTransport(new LearningTransport());
transport.RouteToEndpoint(
assembly: typeof(CreateOrderMessage).Assembly,
destination: "my.orders");
endpointConfiguration.UseSerialization<SystemJsonSerializer>();
var conventions = endpointConfiguration.Conventions();
conventions.DefiningMessagesAs(type =>
typeof(IDTestMessage).IsAssignableFrom(type)
);
return endpointConfiguration;
});
这将学习传输文件置于我的解决方案的根目录中。当在我的泊坞窗内运行时会导致严重的崩溃(在本地工作正常)。所以我想指定用于学习传输文件的文件夹。
根据此处的文档https://docs.pspecial.net/transports/learning/我尝试像这样更新我的代码:
var endpointConfiguration = new EndpointConfiguration("my.orders");
var transport = endpointConfiguration.UseTransport(new LearningTransport());
transport.StorageDirectory("PathToStoreTransportFiles");
transport.RouteToEndpoint(
assembly: typeof(CreateOrderMessage).Assembly,
destination: "my.orders");
我收到此错误:
RoutingSettings' 不包含定义 '存储目录'
也许在 NServicebus 库的 8 版本中,配置的方式有所不同?或者也许我需要安装额外的块?我该如何解决这个问题?
使用新的 v8 方法,您自己创建
LearningTransport
的实例,您需要在实例本身上设置 StorageDirectory
属性。这是一个例子:
var learningTransport = new LearningTransport
{
StorageDirectory = "PathToStoreTransportFiles"
};
var transport = endpointConfiguration.UseTransport(learningTransport);