When raising messages within a saga with the MassTransit transport set to Azure Service Bus the following exception is raised and an error is placed on the error queue:
Put token failed. status-code: 404, status-description:
The messaging entity 'sb://xxxx-prod-bus.servicebus.windows.net/Api/StateMachine-MessageEvent' could not be found.
However, if the saga runs again, the message is successfully published. After looking at the Topic that the message is trying to be published to, the Topic for the first time does not exist but seems to get created afterward, however, the Auto Delete On Idle
property on the Topic is set to 5 minutes so after a period of inactivity the Topic disappears and the error reappears.
The message contracts are declared exactly the same as the MassTransit documentation (https://masstransit-project.com/usage/sagas/automatonymous.html#publish) using an interface and a type to wrap up the saga instance state:
public interface ExampleMessage
{
Guid OrderId { get; }
}
private class ExampleMessageEvent :
ExampleMessage
{
public ExampleMessageEvent(Instance instance)
{
SomeProp = instance.SomeProp;
}
public string SomeProp { get; }
}
Other handlers are only subscribing to the interface of ExampleMessage
, so I'd expect the publish to just continue even if nothing was listening on the concrete type topic?
What is the best way to avoid these issues? I've tried using retries to see if it recreates the exchange however nothing is created on the re-try.
It seems that the default for the temp topic gets the 5 minutes from here . However, I'd expect that if the topic doesn't exist when publishing the message it would just get created again?
The full exception message that was raised is:
Put token failed. status-code: 404, status-description: The messaging entity 'sb://something-prod-bus.servicebus.windows.net/Something.Api/SomethingStateMachine-SomethingRequiredEvent' could not be found. To know more visit https://aka.ms/sbResourceMgrExceptions. TrackingId:2f9c9776-08d5-41ab-81ba-3ec9011c2a90_G49, SystemTracker:something-prod-bus.servicebus.windows.Something.Api/SomethingStateMachine-SomethingRequiredEvent, Timestamp:2019-12-13T23:13:46.
And full stack trace:
Microsoft.Azure.ServiceBus.MessagingEntityNotFoundException:
at Microsoft.Azure.ServiceBus.Core.MessageSender+d__58.MoveNext (Microsoft.Azure.ServiceBus, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Azure.ServiceBus.RetryPolicy+d__19.MoveNext (Microsoft.Azure.ServiceBus, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Azure.ServiceBus.RetryPolicy+d__19.MoveNext (Microsoft.Azure.ServiceBus, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c)
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 Microsoft.Azure.ServiceBus.Core.MessageSender+d__45.MoveNext (Microsoft.Azure.ServiceBus, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c)
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.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+SendClientPipe
1+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 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at 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.PipeContextSupervisor
1+<GreenPipes-IPipeContextSource-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+<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__17
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 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.InMemoryOutboxFilter
1+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 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.ApplicationInsightsConsumeFilter
1+d__14.MoveNext (MassTransit.ApplicationInsights, Version=5.5.6.0, Culture=neutral, PublicKeyToken=b8e0e9f2f1e657fa)