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

如何解决使用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.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?