我们看到一个例外,如果我没记错的话,应该在MT 3.0中修复(我们在3.1上),当我们的环境处于非常高的负载时,我们会看到这一点:
Exception Info: RabbitMQ.Client.Exceptions.AlreadyClosedException
Stack:
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__1(System.Object)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object)
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()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
此异常导致我们的Windows服务崩溃,有人必须重新启动它。我们是否可以在更高级别设置事件或某些配置来处理这些无法预料的情况?
我知道有bus events,但在我的邮件处理之外甚至没有特定的例外情况。
我还看到有exception handling,不幸的是,这仅适用于处理邮件时出错的情况。不适用于RabbitMQ抛出与检索或发送消息无关的异常。
我刚刚添加了一些日志记录和服务级别重新启动逻辑,如果将来可用,将更新此更多详细信息。
AppDomain.CurrentDomain.UnhandledException += UnhandledException;
public void UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
// Shut down, dispose, reinitialize internal objects and log messages.
}
我们在11:37:47看到了这个错误,在所有3个rabbitmq服务器中我们都看到了这些类型的日志:
=INFO REPORT==== 5-May-2016::11:37:06 ===
accepting AMQP connection <0.925.14> (10.50.0.3:59625 -> 10.50.0.123:5672)
=ERROR REPORT==== 5-May-2016::11:37:10 ===
closing AMQP connection <0.917.14> (10.50.0.3:59588 -> 10.50.0.123:5672):
{handshake_timeout,handshake}
=WARNING REPORT==== 5-May-2016::11:37:15 ===
closing AMQP connection <0.614.14> (10.50.0.3:58645 -> 10.50.0.123:5672):
connection_closed_abruptly
=ERROR REPORT==== 5-May-2016::11:37:16 ===
closing AMQP connection <0.925.14> (10.50.0.3:59625 -> 10.50.0.123:5672):
{handshake_timeout,handshake}
=INFO REPORT==== 5-May-2016::11:37:17 ===
accepting AMQP connection <0.941.14> (10.50.0.3:59665 -> 10.50.0.123:5672)
=WARNING REPORT==== 5-May-2016::11:37:24 ===
closing AMQP connection <0.642.14> (10.50.0.3:58726 -> 10.50.0.123:5672):
connection_closed_abruptly
=INFO REPORT==== 5-May-2016::11:37:25 ===
accepting AMQP connection <0.955.14> (10.50.0.3:59774 -> 10.50.0.123:5672)
=WARNING REPORT==== 5-May-2016::11:37:27 ===
closing AMQP connection <0.955.14> (10.50.0.3:59774 -> 10.50.0.123:5672):
connection_closed_abruptly
=ERROR REPORT==== 5-May-2016::11:37:27 ===
closing AMQP connection <0.941.14> (10.50.0.3:59665 -> 10.50.0.123:5672):
{handshake_timeout,handshake}
=INFO REPORT==== 5-May-2016::11:37:29 ===
accepting AMQP connection <0.962.14> (10.50.0.3:59796 -> 10.50.0.123:5672)
=WARNING REPORT==== 5-May-2016::11:37:30 ===
closing AMQP connection <0.670.14> (10.50.0.3:58769 -> 10.50.0.123:5672):
connection_closed_abruptly
=INFO REPORT==== 5-May-2016::11:37:35 ===
accepting AMQP connection <0.972.14> (10.50.0.3:59814 -> 10.50.0.123:5672)
=INFO REPORT==== 5-May-2016::11:37:36 ===
accepting AMQP connection <0.975.14> (10.50.0.3:59824 -> 10.50.0.123:5672)
=WARNING REPORT==== 5-May-2016::11:37:36 ===
closing AMQP connection <0.975.14> (10.50.0.3:59824 -> 10.50.0.123:5672):
connection_closed_abruptly
=ERROR REPORT==== 5-May-2016::11:37:39 ===
closing AMQP connection <0.962.14> (10.50.0.3:59796 -> 10.50.0.123:5672):
{handshake_timeout,handshake}
=INFO REPORT==== 5-May-2016::11:37:44 ===
accepting AMQP connection <0.993.14> (10.50.0.3:59872 -> 10.50.0.123:5672)
=WARNING REPORT==== 5-May-2016::11:37:45 ===
closing AMQP connection <0.705.14> (10.50.0.3:58934 -> 10.50.0.123:5672):
connection_closed_abruptly
=ERROR REPORT==== 5-May-2016::11:37:45 ===
closing AMQP connection <0.972.14> (10.50.0.3:59814 -> 10.50.0.123:5672):
{handshake_timeout,handshake}
=INFO REPORT==== 5-May-2016::11:37:46 ===
accepting AMQP connection <0.1005.14> (10.50.0.3:59881 -> 10.50.0.123:5672)
=WARNING REPORT==== 5-May-2016::11:37:46 ===
closing AMQP connection <0.1005.14> (10.50.0.3:59881 -> 10.50.0.123:5672):
connection_closed_abruptly
=INFO REPORT==== 5-May-2016::11:37:47 ===
accepting AMQP connection <0.1010.14> (10.50.0.3:59892 -> 10.50.0.123:5672)
回过头几分钟,我们会看到几次这样的阻挡:
=INFO REPORT==== 5-May-2016::11:28:25 ===
Mirrored queue 'bus-JEMSO04-w3wp-ktbyyynsicyfb1scbdjzj6targ' in vhost 'Beta': Adding mirror on node rabbit@redisd01: <18045.5072.16>
=INFO REPORT==== 5-May-2016::11:28:25 ===
Mirrored queue 'bus-JEMSO04-w3wp-ktbyyynsicyfb1scbdjzj6targ' in vhost 'Beta': Adding mirror on node rabbit@redisd02: <6520.2073.16>
=INFO REPORT==== 5-May-2016::11:28:25 ===
Mirrored queue 'bus-JEMSO04-w3wp-ktbyyynsicyfb1scbdjzj6targ' in vhost 'Beta': Synchronising: 0 messages to synchronise
=INFO REPORT==== 5-May-2016::11:28:25 ===
Mirrored queue 'bus-JEMSO04-w3wp-ktbyyynsicyfb1scbdjzj6targ' in vhost 'Beta': Synchronising: all slaves already synced
=INFO REPORT==== 5-May-2016::11:28:25 ===
Mirrored queue 'bus-JEMSO04-w3wp-ktbyyynsicyfb1scbdjzj6targ' in vhost 'Beta': Synchronising: 0 messages to synchronise
=INFO REPORT==== 5-May-2016::11:28:25 ===
Mirrored queue 'bus-JEMSO04-w3wp-ktbyyynsicyfb1scbdjzj6targ' in vhost 'Beta': Synchronising: all slaves already synced
=ERROR REPORT==== 5-May-2016::11:28:26 ===
closing AMQP connection <0.32168.13> (10.50.0.3:47716 -> 10.50.0.123:5672):
{handshake_timeout,handshake}
我们在升级后有一个新问题,这是来自我们的消费者并且没有负载:
MassTransit.Util.TaskSupervisor Error: 0 : Failed to close scope MassTransit.RabbitMqTransport.Pipeline.RabbitMqBasicConsumer - rabbitmq://rabbitmqdlb.jsa.local:5672/LocalDev/bus-MRHODEN-DT-Se
rvice.vshost-xabyyydu3ecy84dibdjamdsbrb?prefetch=16, System.Threading.Tasks.TaskCanceledException: A task was canceled.
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
at MassTransit.RabbitMqTransport.Pipeline.RabbitMqBasicConsumer.<Stop>d__32.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 System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
at MassTransit.Util.TaskSupervisorExtensions.<>c__DisplayClass2_0.<<CreateParticipant>b__0>d.MoveNext()