我在同一个IIS实例上运行了2个ASP.NET api,它们在同一个队列中使用MassTransit但仅用于发送。
在启动时,两个api都会创建自己的总线'然而,它们似乎以某种方式相互冲突,最终两个总线队列都将消失,同样的错误将每隔几个小时反复发生:
ERROR - Failed to close scope MassTransit.RabbitMqTransport.Pipeline.RabbitMqBasicConsumer -rabbitmq://<host>/bus-DEV-API-w3wp-364yyynqbn68pfb5bdj5ic3kfr?durable=false&autodelete=true&prefetch=4
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 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 MassTransit.Util.TaskSupervisorExtensions.<>c__DisplayClass2_0.<<CreateParticipant>b__0>d.MoveNext()
这是我的配置,它出现在我的WebApiApplication的Application_Start()中,并被分配给一个公共静态变量:
MassTransit.Bus.Factory.CreateUsingRabbitMq(cfg =>
{
cfg.Host(new Uri(QueueEndpoints.HostBase), h =>
{
h.Username("guest");
h.Password("guest");
});
cfg.UseLog4Net();
});