【发布时间】:2020-11-16 05:49:45
【问题描述】:
在将 MassTransit 传输设置为 Azure 服务总线的 saga 中引发消息时,将引发以下异常,并将错误置于错误队列中:
放置令牌失败。状态码:404,状态描述:
找不到消息传递实体“sb://xxxx-prod-bus.servicebus.windows.net/Api/StateMachine-MessageEvent”。
但是,如果 saga 再次运行,则消息已成功发布。查看消息试图发布到的主题后,第一次主题不存在,但似乎是之后创建的,但是,主题上的 Auto Delete On Idle 属性设置为 5 分钟,所以经过一段时间不活动主题消失,错误再次出现。
消息契约的声明与 MassTransit 文档 (https://masstransit-project.com/usage/sagas/automatonymous.html#publish) 完全相同,使用接口和类型来包装 saga 实例状态:
public interface ExampleMessage
{
Guid OrderId { get; }
}
private class ExampleMessageEvent :
ExampleMessage
{
public ExampleMessageEvent(Instance instance)
{
SomeProp = instance.SomeProp;
}
public string SomeProp { get; }
}
其他处理程序只订阅ExampleMessage 的接口,所以我希望即使没有人在监听具体类型主题,发布也会继续?
避免这些问题的最佳方法是什么?我尝试使用重试来查看它是否重新创建了交换,但是重试时没有创建任何内容。
似乎 temp 主题的默认值从 here 获得了 5 分钟 .但是,我希望如果发布消息时主题不存在,它会再次创建?
引发的完整异常消息是:
放置令牌失败。状态代码:404,状态描述:找不到消息传递实体 'sb://something-prod-bus.servicebus.windows.net/Something.Api/SomethingStateMachine-SomethingRequiredEvent'。要了解更多信息,请访问https://aka.ms/sbResourceMgrExceptions。 TrackingId:2f9c9776-08d5-41ab-81ba-3ec9011c2a90_G49,SystemTracker:something-prod-bus.servicebus.windows.Something.Api/SomethingStateMachine-SomethingRequiredEvent,时间戳:2019-12-13T23:13:46。
以及完整的堆栈跟踪:
Microsoft.Azure.ServiceBus.MessagingEntityNotFoundException:
在 Microsoft.Azure.ServiceBus.Core.MessageSender+d__58.MoveNext(Microsoft.Azure.ServiceBus,版本=4.0.0.0,文化=中性,PublicKeyToken=7e34167dcc6d6d8c)
在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(System.Private.CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken=7cec85d7bea7798e)
在 Microsoft.Azure.ServiceBus.RetryPolicy+d__19.MoveNext(Microsoft.Azure.ServiceBus,版本=4.0.0.0,文化=中性,PublicKeyToken=7e34167dcc6d6d8c)
在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(System.Private.CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken=7cec85d7bea7798e)
在 Microsoft.Azure.ServiceBus.RetryPolicy+d__19.MoveNext(Microsoft.Azure.ServiceBus,版本=4.0.0.0,文化=中性,PublicKeyToken=7e34167dcc6d6d8c)
在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(System.Private.CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken=7cec85d7bea7798e)
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Private.CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken=7cec85d7bea7798e)
在 Microsoft.Azure.ServiceBus.Core.MessageSender+d__45.MoveNext(Microsoft.Azure.ServiceBus,版本=4.0.0.0,文化=中性,PublicKeyToken=7e34167dcc6d6d8c)
在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(System.Private.CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken=7cec85d7bea7798e)
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Private.CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken=7cec85d7bea7798e)
在 MassTransit.Azure.ServiceBus.Core.Transport.ServiceBusSendTransport+SendClientPipe1+<Send>d__5.MoveNext (MassTransit.Azure.ServiceBus.Core, Version=5.5.6.0, Culture=neutral, PublicKeyToken=b8e0e9f2f1e657fa) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at MassTransit.Azure.ServiceBus.Core.Transport.ServiceBusSendTransport+SendClientPipe1+d__5.MoveNext(MassTransit.Azure.ServiceBus.Core,版本=5.5.6.0,文化=中性,PublicKeyToken=b8e0e9f2f1e657fa)
在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(System.Private.CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken=7cec85d7bea7798e)
在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Private.CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken=7cec85d7bea7798e) 在 GreenPipes.Agents.PipeContextSupervisor1+<GreenPipes-IPipeContextSource<TContext>-Send>d__8.MoveNext (GreenPipes, Version=2.1.4.118, Culture=neutral, PublicKeyToken=b800c4cfcdeea87b) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at GreenPipes.Agents.PipeContextSupervisor1+d__8.MoveNext(GreenPipes,版本=2.1.4.118,文化=中性,PublicKeyToken=b800c4cfcdeea87b) 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(System.Private.CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken=7cec85d7bea7798e) 在 GreenPipes.Agents.PipeContextSupervisor 1+<GreenPipes-IPipeContextSource<TContext>-Send>d__8.MoveNext (GreenPipes, Version=2.1.4.118, Culture=neutral, PublicKeyToken=b800c4cfcdeea87b) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at MassTransit.Transports.PublishEndpoint+<Publish>d__171.MoveNext(MassTransit,版本=5.5.6.0,文化=中性,PublicKeyToken=b8e0e9f2f1e657fa) 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(System.Private.CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken=7cec85d7bea7798e) 在 MassTransit.Transports.PublishEndpoint+d__171.MoveNext (MassTransit, Version=5.5.6.0, Culture=neutral, PublicKeyToken=b8e0e9f2f1e657fa) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at MassTransit.Context.InMemoryOutboxConsumeContext+<ExecutePendingActions>d__10.MoveNext (MassTransit, Version=5.5.6.0, Culture=neutral, PublicKeyToken=b8e0e9f2f1e657fa) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at MassTransit.Pipeline.Filters.InMemoryOutboxFilter1+d__1.MoveNext(MassTransit,版本=5.5.6.0,文化=中性,PublicKeyToken=b8e0e9f2f1e657fa) 在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(System.Private.CoreLib,版本=4.0.0.0,文化=中性,PublicKeyToken=7cec85d7bea7798e) 在 MassTransit.Pipeline.Filters.InMemoryOutboxFilter1+<Send>d__1.MoveNext (MassTransit, Version=5.5.6.0, Culture=neutral, PublicKeyToken=b8e0e9f2f1e657fa) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at MassTransit.ApplicationInsights.Pipeline.ApplicationInsightsConsumeFilter1+d__14.MoveNext(MassTransit.ApplicationInsights,版本=5.5.6.0,Culture=neutral,PublicKeyToken=b8e0e9f2f1e657fa)
【问题讨论】:
-
您有示例异常吗?我想知道是否存在我需要修复的主题创建的排序/依赖问题。
-
@ChrisPatterson 我刚刚将完整的异常消息和堆栈跟踪添加到问题中。
-
啊,我认为是不活动的时期。我应该更改发送端点代码,以便如果它正在发送到一个临时实体,并且经过的时间接近该生命周期,它会重置并重新创建该实体以确保它在经过的时间之后存在。
标签: azureservicebus masstransit