Reputation: 617
I'm using MassTransit version 8.3.6 with Azure Service Bus, and I'm trying to utilize the delayed re-delivery feature in MassTransit. However, as soon as I enqueue the message, I encounter the following error in my logs:
MassTransit.MessageTimeToLiveExpiredException: sb://providerappapiv2.servicebus.windows.net/note => The message expired: ac5a0000da2bb05c4b6f08dd5518d768
When I remove this line from the configuration:
e.UseDelayedRedelivery(r => r.Intervals(TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(15), TimeSpan.FromMinutes(30)));
everything works as expected.
What am I doing wrong?
Here's my configuration code:
services.AddMassTransit(x =>
{
x.SetKebabCaseEndpointNameFormatter();
x.AddConsumer<NoteConsumer>();
x.UsingAzureServiceBus((context, cfg) =>
{
cfg.Host(config.GetConnectionString("AzureServiceBus"));
cfg.UseServiceBusMessageScheduler();
cfg.ReceiveEndpoint("note", e =>
{
e.DefaultMessageTimeToLive = TimeSpan.FromDays(14);
e.EnableDeadLetteringOnMessageExpiration = true;
e.MaxDeliveryCount = 15;
e.DuplicateDetectionHistoryTimeWindow = TimeSpan.FromMinutes(10);
e.MaxSizeInMegabytes = 5120;
e.RequiresDuplicateDetection = true;
e.UseDelayedRedelivery(r => r.Intervals(TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(15), TimeSpan.FromMinutes(30)));
e.UseMessageRetry(r => r.Intervals(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(8)));
if (e is IServiceBusReceiveEndpointConfigurator sb)
{
sb.ConfigureDeadLetterQueueDeadLetterTransport();
sb.ConfigureDeadLetterQueueErrorTransport();
}
e.ConfigureConsumer<NoteConsumer>(context);
});
cfg.ConfigureEndpoints(context);
});
x.AddMediator(cfg =>
{
//...
});
});
Any insights into what might be going wrong would be appreciated.
EDIT: The TTL exception issue occurs only when the queue is not created before starting the application. If the queue already exists, the message is delivered with a retry; however, delayed re-delivery still does not work.
Upvotes: 0
Views: 33