问题描述
我正在使用Rebus.Async通过命令CQRS将处理数据回复到WebApi请求。
1。我使用以下配置注册了总线:
public static IContainerRegistry RegisterRebusInMemory(
this IContainerRegistry containerRegistry)
{
switch (_containerAdapter)
{
default: // SimpleInjector
return RegisterRebusInMemoryWithSimpleInjectorContainer(containerRegistry);
}
}
private static IContainerRegistry RegisterRebusInMemoryWithSimpleInjectorContainer(
IContainerRegistry containerRegistry)
{
var rebusQueue = "rebusMessages";
Container container = (Container)containerRegistry.Container;
RegisterRebus(containerRegistry);
container.ConfigureRebus(
configurer => configurer
.Logging(l => l.Console())
.Serialization(s => s.UseNewtonsoftJson(NewtonsoftSettings,Encoding.UTF8))
.Options(o =>
{
o.EnableSynchronousRequestReply();
o.SetNumberOfWorkers(1);
o.SetMaxParallelism(1);
})
.Transport(t => t.UseInMemoryTransport(new InMemNetwork(),rebusQueue))
.Routing(r =>
{
r.TypeBased()
.MapAssemblyOf<IDomainNotification>(rebusQueue)
.MapAssemblyOf<DefaultReplyCommand>(rebusQueue)
.MapCommands(rebusQueue)
.MapEvents(rebusQueue);
})
.Sagas(sagas => sagas.StoreInMemory())
.Subscriptions(s => s.StoreInMemory())
.Start()
);
return containerRegistry;
}
public class MyCommandHandler : CommandHandler,IHandleMessages<MyCommand>
{
...
public async Task Handle(MyCommand message)
{
DefaultReplyCommand defaultReply = new DefaultReplyCommand(message.AggregateId);
// Do some stuffs
await _bus.Reply(_reply);
}
...
}
3。当我发送等待_bus.Reply(_reply)的回复时,抛出以下异常:
[WRN] Rebus.Retry.ErrorTracking.InMemErrorTracker(任务1的工作者1):处理ID为“ request-reply_3452be37-fdfd-4115-89a2-504b4feae22f”的消息时,未处理的异常1(FINAL)Rebus.Exceptions.MessageCouldNotBedispatchedToAnyHandlersException: ID为request-reply_3452be37-fdfd-4115-89a2-504b4feae22f且类型为AgroHUB.Application.Cattle.Commands.CattleOperation.MoveCattleOperationCommand,AgroHUB.Application.Cattle的消息无法分派给任何处理程序(并且不会在默认失败下重试) -快速设置)
at Rebus.Pipeline.Receive.dispatchIncomingMessageStep.Process(IncomingStepContext context,Func`1 next)
at Rebus.Sagas.LoadSagaDataStep.Process(IncomingStepContext context,Func`1 next)
at Rebus.Pipeline.Receive.ActivateHandleRSStep.Process(IncomingStepContext context,Func`1 next)
at Rebus.Internals.ReplyHandlerStep.Process(IncomingStepContext context,Func`1 next)
at Rebus.Pipeline.Receive.HandleRoutingSlipsstep.Process(IncomingStepContext context,Func`1 next)
at Rebus.Pipeline.Receive.DeserializeIncomingMessageStep.Process(IncomingStepContext context,Func`1 next)
at Rebus.DataBus.ClaimCheck.HydrateIncomingMessageStep.Process(IncomingStepContext context,Func`1 next)
at Rebus.Pipeline.Receive.HandleDeferredMessagesstep.Process(IncomingStepContext context,Func`1 next)
at Rebus.Retry.FailFast.FailFastStep.Process(IncomingStepContext context,Func`1 next)
at Rebus.Retry.Simple.SimpleRetryStrategyStep.dispatchWithTrackerIdentifier(Func`1 next,String identifierToTrackMessageBy,ITransactionContext transactionContext,String messageId,String secondLevelMessageId)
Cenario
Rebus.Async与本机C#依赖关系注入(service.AddScope)一起使用,但是当我将de Cointainer更改为使用Simple Injector时,答复不再起作用。
要使用Rebus.Async与Simple Injector进行一些额外的配置吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)