NServiceBus 在失去与 RabbitMQ 主机的连接时崩溃
NServiceBus crashes when losing connectivity to RabbitMQ host
我们遇到了一个问题,即 NServiceBus 在与 RabbitMQ 服务器失去连接后大约 4-5 分钟后崩溃。
为了重现,我启动了我的应用程序,看到 RabbitMQ 看到了连接,断开了我的网线,然后等待。大约 5 分钟后,NServiceBus 主机崩溃了。
在 Debug 运行 时,我收到以下错误消息:
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.
在我们的服务器上,事件日志中有以下内容:
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 服务器的断开连接?
发生这种情况是因为断路器确保服务不会挂起,而是在无法执行其工作时关闭。
您可以将端点配置为在连接断开时有更长的超时时间,请参阅"controlling behavior when broker connection is lost" for more information
此外,您可以将服务恢复设置为在失败时重新启动。
我们遇到了一个问题,即 NServiceBus 在与 RabbitMQ 服务器失去连接后大约 4-5 分钟后崩溃。
为了重现,我启动了我的应用程序,看到 RabbitMQ 看到了连接,断开了我的网线,然后等待。大约 5 分钟后,NServiceBus 主机崩溃了。
在 Debug 运行 时,我收到以下错误消息:
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.
在我们的服务器上,事件日志中有以下内容:
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 服务器的断开连接?
发生这种情况是因为断路器确保服务不会挂起,而是在无法执行其工作时关闭。
您可以将端点配置为在连接断开时有更长的超时时间,请参阅"controlling behavior when broker connection is lost" for more information
此外,您可以将服务恢复设置为在失败时重新启动。