使用SimpleInjector请求/回复MessageCouldNotBeDispatchedToAnyHandlersException的Rebus.Async

问题描述

我正在使用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;
}

2。我创建了一个用于请求/回复的句柄:

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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...