Rebus 中未处理的随机消息
Random Messages Not Being Handled in Rebus
我在实施 Rebus 时遇到了一个奇怪的问题,它在过去几年一直没有出现任何问题,我正试图找出问题的范围以及我的故障排除工作的重点。一点背景:
- 我们已经运行版本0.99.66
- 上周移动到版本 3.1.5,然后发现问题出现
- 回滚到 0.99.66,问题继续
- 使用 MSMQ 进行传输
- 运行 Windows 服务器 2016
- 其他服务器实例上的相同代码运行没有问题
因此,我们遇到了看似随机的消息失败实例,最终出现在错误队列中,并出现 Rebus 错误,表明无法将消息分派给任何处理程序。这种情况可能发生一次,但下次收到相同类型的消息时,它会得到正确处理。
这里是有问题的代码片段:
public class ProcessManagerService
{
public ProcessManagerService()
{
...
BusAdapter = new BuiltinHandlerActivator();
BusAdapter.Handle<FileEventMessage>(async msg => await StartProcess(msg));
BusAdapter.Handle<ProcessRequest>(async msg => await StartProcess(msg));
Bus = Configure.With(BusAdapter)
.Logging(l => l.ColoredConsole(LogLevel.Error))
.Transport(t => t.UseMsmq(ConfigurationManager.AppSettings["Queue"]))
.Start();
}
...
public async Task StartProcess(FileEventMessage msg)
{
var svc = new StepManager() { FileEvent = msg.FileEvent };
await svc.Run();
}
public async Task StartProcess(ProcessRequest msg)
{
var svc = new StepManager();
await svc.Run(msg);
}
}
下面是抛出异常的示例:
5 unhandled exceptions: 12/18/2018 7:53:00 AM -06:00:
Rebus.Exceptions.RebusApplicationException: Message with ID
c72a8b6d-e31c-4a88-937e-612bf1db8b11 and type
ClearStone.Messages.Monitoring.File.FileEventMessage,
ClearStone.Messages could not be dispatched to any handlers at
Rebus.Pipeline.Receive.DispatchIncomingMessageStep.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.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.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.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.Pipeline.Receive.HandleDeferredMessagesStep.d__12.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.d__8.MoveNext()
更新:这是在 Rebus 源中连接后更详细的堆栈跟踪:
5 unhandled exceptions: 12/20/2018 9:39:05 AM -06:00: Rebus.Exceptions.RebusApplicationException: Message with ID 84c3605a-41de-4300-9596-97e7288d2bcb and type ClearStone.Messages.Monitoring.File.FileEventMessage, ClearStone.Messages could not be dispatched to any handlers
at Rebus.Pipeline.Receive.DispatchIncomingMessageStep.d__1.MoveNext() in C:\Temp\rebus_0_99_66_archive\Rebus\Pipeline\Receive\DispatchIncomingMessageStep.cs:line 61
--- 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 System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Rebus.Sagas.LoadSagaDataStep.d__7.MoveNext() in C:\Temp\rebus_0_99_66_archive\Rebus\Sagas\LoadSagaDataStep.cs:line 77
--- 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 System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Rebus.Pipeline.Receive.ActivateHandlersStep.d__3.MoveNext() in C:\Temp\rebus_0_99_66_archive\Rebus\Pipeline\Receive\ActivateHandlersStep.cs:line 48
--- 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 System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Rebus.Pipeline.Receive.DeserializeIncomingMessageStep.d__2.MoveNext() in C:\Temp\rebus_0_99_66_archive\Rebus\Pipeline\Receive\DeserializeIncomingMessageStep.cs:line 36
--- 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 System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Rebus.Pipeline.Receive.HandleDeferredMessagesStep.d__12.MoveNext() in C:\Temp\rebus_0_99_66_archive\Rebus\Pipeline\Receive\HandleDeferredMessagesStep.cs:line 114
--- 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 System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Rebus.Retry.Simple.SimpleRetryStrategyStep.d__8.MoveNext() in C:\Temp\rebus_0_99_66_archive\Rebus\Retry\Simple\SimpleRetryStrategyStep.cs:line 105
假设这很明显,并且它是这个特定服务器中的某些东西 instance/enviornment,我试图弄清楚为什么 Rebus 会这样,以及我的环境中可能导致这种情况的原因。任何关于从哪里开始寻找的方向将不胜感激!
听起来很奇怪 :) 当人们遇到这个问题时,几乎总是因为他们以某种方式设置了多个 Rebus 实例来使用同一队列中的消息。
在极少数情况下,这是因为 .Start()
在总线上被调用 在 处理程序被添加到 container/built-in 处理程序激活器之前,但事实并非如此这似乎不是你的问题。
你能告诉我更多关于你的设置的信息吗?如果它和上面显示的一样简单,也许您可以在单独的应用程序中重现它?
我在实施 Rebus 时遇到了一个奇怪的问题,它在过去几年一直没有出现任何问题,我正试图找出问题的范围以及我的故障排除工作的重点。一点背景:
- 我们已经运行版本0.99.66
- 上周移动到版本 3.1.5,然后发现问题出现
- 回滚到 0.99.66,问题继续
- 使用 MSMQ 进行传输
- 运行 Windows 服务器 2016
- 其他服务器实例上的相同代码运行没有问题
因此,我们遇到了看似随机的消息失败实例,最终出现在错误队列中,并出现 Rebus 错误,表明无法将消息分派给任何处理程序。这种情况可能发生一次,但下次收到相同类型的消息时,它会得到正确处理。
这里是有问题的代码片段:
public class ProcessManagerService
{
public ProcessManagerService()
{
...
BusAdapter = new BuiltinHandlerActivator();
BusAdapter.Handle<FileEventMessage>(async msg => await StartProcess(msg));
BusAdapter.Handle<ProcessRequest>(async msg => await StartProcess(msg));
Bus = Configure.With(BusAdapter)
.Logging(l => l.ColoredConsole(LogLevel.Error))
.Transport(t => t.UseMsmq(ConfigurationManager.AppSettings["Queue"]))
.Start();
}
...
public async Task StartProcess(FileEventMessage msg)
{
var svc = new StepManager() { FileEvent = msg.FileEvent };
await svc.Run();
}
public async Task StartProcess(ProcessRequest msg)
{
var svc = new StepManager();
await svc.Run(msg);
}
}
下面是抛出异常的示例:
5 unhandled exceptions: 12/18/2018 7:53:00 AM -06:00: Rebus.Exceptions.RebusApplicationException: Message with ID c72a8b6d-e31c-4a88-937e-612bf1db8b11 and type ClearStone.Messages.Monitoring.File.FileEventMessage, ClearStone.Messages could not be dispatched to any handlers at Rebus.Pipeline.Receive.DispatchIncomingMessageStep.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.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.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.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.Pipeline.Receive.HandleDeferredMessagesStep.d__12.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.d__8.MoveNext()
更新:这是在 Rebus 源中连接后更详细的堆栈跟踪:
5 unhandled exceptions: 12/20/2018 9:39:05 AM -06:00: Rebus.Exceptions.RebusApplicationException: Message with ID 84c3605a-41de-4300-9596-97e7288d2bcb and type ClearStone.Messages.Monitoring.File.FileEventMessage, ClearStone.Messages could not be dispatched to any handlers at Rebus.Pipeline.Receive.DispatchIncomingMessageStep.d__1.MoveNext() in C:\Temp\rebus_0_99_66_archive\Rebus\Pipeline\Receive\DispatchIncomingMessageStep.cs:line 61 --- 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 System.Runtime.CompilerServices.TaskAwaiter.GetResult() at Rebus.Sagas.LoadSagaDataStep.d__7.MoveNext() in C:\Temp\rebus_0_99_66_archive\Rebus\Sagas\LoadSagaDataStep.cs:line 77 --- 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 System.Runtime.CompilerServices.TaskAwaiter.GetResult() at Rebus.Pipeline.Receive.ActivateHandlersStep.d__3.MoveNext() in C:\Temp\rebus_0_99_66_archive\Rebus\Pipeline\Receive\ActivateHandlersStep.cs:line 48 --- 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 System.Runtime.CompilerServices.TaskAwaiter.GetResult() at Rebus.Pipeline.Receive.DeserializeIncomingMessageStep.d__2.MoveNext() in C:\Temp\rebus_0_99_66_archive\Rebus\Pipeline\Receive\DeserializeIncomingMessageStep.cs:line 36 --- 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 System.Runtime.CompilerServices.TaskAwaiter.GetResult() at Rebus.Pipeline.Receive.HandleDeferredMessagesStep.d__12.MoveNext() in C:\Temp\rebus_0_99_66_archive\Rebus\Pipeline\Receive\HandleDeferredMessagesStep.cs:line 114 --- 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 System.Runtime.CompilerServices.TaskAwaiter.GetResult() at Rebus.Retry.Simple.SimpleRetryStrategyStep.d__8.MoveNext() in C:\Temp\rebus_0_99_66_archive\Rebus\Retry\Simple\SimpleRetryStrategyStep.cs:line 105
假设这很明显,并且它是这个特定服务器中的某些东西 instance/enviornment,我试图弄清楚为什么 Rebus 会这样,以及我的环境中可能导致这种情况的原因。任何关于从哪里开始寻找的方向将不胜感激!
听起来很奇怪 :) 当人们遇到这个问题时,几乎总是因为他们以某种方式设置了多个 Rebus 实例来使用同一队列中的消息。
在极少数情况下,这是因为 .Start()
在总线上被调用 在 处理程序被添加到 container/built-in 处理程序激活器之前,但事实并非如此这似乎不是你的问题。
你能告诉我更多关于你的设置的信息吗?如果它和上面显示的一样简单,也许您可以在单独的应用程序中重现它?