C# 带有SimpleInjector请求/回复消息的Rebus.Async不能被DispatchedToAnyHandlersException

C# 带有SimpleInjector请求/回复消息的Rebus.Async不能被DispatchedToAnyHandlersException,c#,simple-injector,rebus,C#,Simple Injector,Rebus,我正在使用Rebus.Async使用命令CQRS向WebApi请求回复处理数据 1。我使用以下配置注册了总线: 公共静态IContainerRegistry注册表RebusinMemory( 此IContainerRegistry(包含注册) { 开关(_容器适配器) { 默认值://SimpleInjector 返回注册表reBusinMemoryWithSimpleInjectorContainer(containerRegistry); } } 私有静态IContainerRegistry

我正在使用Rebus.Async使用命令CQRS向WebApi请求回复处理数据

1。我使用以下配置注册了总线:

公共静态IContainerRegistry注册表RebusinMemory(
此IContainerRegistry(包含注册)
{
开关(_容器适配器)
{
默认值://SimpleInjector
返回注册表reBusinMemoryWithSimpleInjectorContainer(containerRegistry);
}
}
私有静态IContainerRegistry注册表注册表使用SimpleInjectContainer(
IContainerRegistry(容器注册)
{
var reusqueue=“重新消息”;
Container Container=(Container)containerRegistry.Container;
注册表总线(containerRegistry);
container.ConfigureRebus(
configurer=>configurer
.Logging(l=>l.Console())
.Serialization(s=>s.UseNewtonsoftJson(NewtonsoftSettings,Encoding.UTF8))
.选项(o=>
{
o、 启用SynchronousRequestReply();
o、 设定工人人数(1);
o、 SetMaxParallelism(1);
})
.Transport(t=>t.useinmemoryttransport(新的InMemNetwork(),重新压缩))
.路由(r=>
{
r、 基于类型的()
.MapAssemblyOf(重新排队)
.MapAssemblyOf(重新排队)
.MapCommands(重新压缩)
.MapEvents(重新创建);
})
.Sagas(Sagas=>Sagas.StoreInMemory())
.Subscriptions(s=>s.StoreInMemory())
.Start()
);
返回容器注册;
}
2。我创建了一个用于请求/回复的句柄:

公共类MyCommandHandler:CommandHandler,IHandleMessages
{
...
公共异步任务句柄(MyCommand消息)
{
DefaultReplyCommand defaultReply=新的DefaultReplyCommand(message.AggregateId);
//做些事情
等待巴士回复(回复);
}
...
}
3。当我使用等待总线发送回复时,reply(\u reply)抛出以下异常:

[WRN]Rebus.Retry.ErrorTracking.InMemErrorTracker(Rebus 1 worker 1):处理ID为“request-reply_3452be37-FDFDFD-4115-89a2-504b4feae22f”的消息时未处理的异常1(最终)Rebus.Exceptions.Message无法分派到任何处理程序异常:ID为request-reply_3452be37-fdfd-4115-89a2-504b4feae22f且类型为AgroHUB.Application.Bown.Commands.CattleOperation.MoveCattleOperationCommand、AgroHUB.Application.Bown的消息无法分派到任何处理程序(在默认fail fast设置下不会重试)

塞纳里奥

Async与本机C#依赖项注入(service.AddScope)一起工作,但是当我将decointainer更改为使用简单注入时,应答就不再工作了


有一些额外的配置可以将Rebus.Async与简单注入器一起使用?

似乎没有在IoC容器中注册的
MoveCattleOperationCommand
的处理程序。是否调用了
container.Register(typeof(IHandleMessages),assembly)
或类似的东西?噢,我的错。我忘记用
typeof(IHandleMessages)
注册处理程序。我将代码从
handlers.ForEach(hdl=>containerRegistry.register(hdl,hdl))
更改为以下
containerRegistry.register(typeof(IHandleMessages),handlers)
处理程序已成功使用。谢谢@Steven:)您也应该感谢@mookid8000。他的评论触动了我。当然。感谢@mookid8000的回答,并向大家致意,感谢这个令人敬畏的rebus项目!似乎IoC容器中没有注册的
MoveCattleOperationCommand
处理程序。您是否调用了
container.Register(typeof(IHandleMessages)、assembly)
或类似的东西?oops。我的错。我忘了用
typeof(IHandleMessages)
注册处理程序。我将代码从
handlers.ForEach(hdl=>containerRegistry.Register(hdl,hdl))
更改为以下
containerRegistry.Register(typeof(IHandleMessages),handlers)
,处理程序被成功使用。谢谢@Steven:)你也应该感谢@mookid8000。他的评论触动了我。当然。感谢@mookid8000的回答,并向大家致意,感谢这个令人敬畏的rebus项目!
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)