【发布时间】:2019-11-27 12:58:03
【问题描述】:
我在 Asp.Net Core 应用程序中有一个简单的 saga 配置:
services.AddSingleton<ISagaRepository<Request>, InMemorySagaRepository<Request>>();
services.AddMassTransit(x =>
{
x.AddSagaStateMachine<RequestStateMachine, Request>();
x.AddRequestClient<IRequestCreated>();
x.AddBus(provider => Bus.Factory.CreateUsingInMemory(cfg =>
{
cfg.UseInMemoryOutbox();
cfg.ConfigureEndpoints(provider);
}));
});
如果稍后我通过 IRequestClient<IRequestCreated> 向 Saga 发送消息:
var client = context.RequestServices.GetService<IRequestClient<IRequestCreated>>();
var response = await client.GetResponse<RequestCreatedResponse>(new
{
CorrelationId = Guid.NewGuid(),
ClientId = 1,
});
一切正常。但是如果我在IBus 上尝试同样的事情:
var mtbus = context.RequestServices.GetService<IBus>();
await mtbus.Send<IRequestCreated>(new
{
CorrelationId = Guid.NewGuid(),
ClientId = 1,
});
我收到错误A convention for the message type Sample.AspNetCore.Host.Saga.IRequestCreated was not found
我错过了什么?
【问题讨论】:
标签: c# asp.net-core masstransit saga