映射事件抛出

Mapped Event throws

我已经映射了程序集中的所有 类。当启动 Rebus 时,它应该提到:

Mapped MyNamespace.Events.EmailSend -> Rebus/Test/Input

但是当我尝试使用以下代码在处理程序中提交消息时出现错误:

await _bus.Send(new EmailSend
{
    MyProperty = 1
}).ConfigureAwait(false);

我也尝试使用 .Reply().SendLocal(),但这并不能帮助我摆脱下面的错误。

堆栈跟踪:

Rebus.Retry.ErrorTracking.InMemErrorTracker WARN (Thread #10): Unhandled exception 1 while handling message with ID a2c3b234-f519-4d86-bec9-715b2045ef94: Rebus.Exceptions.RebusApplicationException: Message with ID a2c3b234-f519-4d86-bec9-715b2045ef94 and type MyNamespace.Events.EmailSend, MyAssembly.Messaging.Models could not be dispatched to any handlers
at Rebus.Pipeline.Receive.DispatchIncomingMessageStep.<Process>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Rebus.Sagas.LoadSagaDataStep.<Process>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Rebus.Pipeline.Receive.ActivateHandlersStep.<Process>d__3.MoveNext()
 --- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Rebus.Pipeline.Receive.DeserializeIncomingMessageStep.<Process>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Rebus.Retry.Simple.SimpleRetryStrategyStep.<DispatchWithTrackerIdentifier>d__7.MoveNext()

第一行真的说明了一切:

Rebus.Retry.ErrorTracking.InMemErrorTracker WARN (Thread #10): Unhandled exception 1 while handling message with ID a2c3b234-f519-4d86-bec9-715b2045ef94: Rebus.Exceptions.RebusApplicationException: Message with ID a2c3b234-f519-4d86-bec9-715b2045ef94 and type MyNamespace.Events.EmailSend, MyAssembly.Messaging.Models could not be dispatched to any handlers

注意最后一部分:

Message with ID a2c3b234-f519-4d86-bec9-715b2045ef94 and type MyNamespace.Events.EmailSend, MyAssembly.Messaging.Models could not be dispatched to any handlers

这意味着 Rebus 找不到消息的处理程序,即 IHandleMessages<EmailSend> 的实现。

如果您使用的是 IoC 容器,这 可以 表明,虽然您可能已经正确注册了处理程序类型,但它的一个依赖项无法解析。

如果您没有注册处理程序:我想这很明显:)

正在使用 .ConfigureAwait(true) 调用 _bus.Send(),从总线提交消息时似乎需要 "false"。

哦,处理程序 class 是内部的。

猜猜其中一个是真正的问题 - 或者两者兼而有之...