2

我们遇到了一个问题,即 NServiceBus 在与 RabbitMQ 服务器的连接丢失后大约 4-5 分钟后崩溃。

为了重现,我启动了我的应用程序,看到 RabbitMQ 看到了连接,断开了我的网线,然后等待。大约 5 分钟后,NServiceBus 主机崩溃了。

在调试中运行时,我收到以下错误消息:

Additional information: The runtime has encountered a fatal error. The address of the error was at 0xf6a94323, on thread 0xf8b8. The error code is 0x80131623. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

在我们的服务器上,EventLog 中有以下内容:

Application: NServiceBus.Host.exe
Framework Version: v4.0.30319
Description: The application requested process termination through System.Environment.FailFast(string message).
Message: The following critical error was encountered by NServiceBus:
Repeated failures when communicating with the broker
    NServiceBus is shutting down.
    Stack:
       at System.Environment.FailFast(System.String, System.Exception)
       at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
       at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
       at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
       at System.Threading.ThreadPoolWorkQueue.Dispatch()

这是我们的 RabbitMQ 连接字符串:

<add name="NServiceBus/Transport" connectionString="host=our_host_address;VirtualHost=OurVirtualHost;UserName=OurUser;Password=******;PrefetchCount=1;DequeueTimeout=30" />

是什么导致了这次崩溃?有没有办法从中恢复/抓住它?我们如何优雅地处理与 RabbitMQ 服务器的断开连接?

4

1 回答 1

2

发生这种情况是因为断路器确保服务不会挂起,而是在无法完成工作时关闭。

如果连接断开,您可以将端点配置为具有更长的超时时间,有关更多信息,请参阅“代理连接丢失时的控制行为”

此外,您可以将服务恢复设置为在失败时重新启动。

于 2016-04-12T15:44:11.113 回答