Our Mass Transit / Azure Service Bus setup is working pretty well, but there's one feature left over that we'd really like to use, but doesn't seem to be working - scheduled redelivery.
Here is the code in Startup:
busFactoryConfig.UseServiceBusMessageScheduler();
busFactoryConfig.SubscriptionEndpoint(Constants.SubscriptionName, Constants.TopicName, configurator =>
{
configurator.UseScheduledRedelivery(r => r.Intervals(TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(15), TimeSpan.FromMinutes(30)));
configurator.UseMessageRetry(r =>
{
r.Immediate(2);
r.Ignore<InvalidCastException>(); //we don't want to retry here, the message content is invalid
});
This seems to match up well with the documentation. Although the documentation seems to only refer to RabbitMQ.
However, when this actually triggers, a masstransit exception is thrown, and the redelivery doesn't work. This is using .NET Core 3.1, MassTransit 7.0.1 and Azure Service Bus Topics.
Error (intentionally thrown to trigger the retries):
MassTransit.TransportException: **ADDRESS** => The message delivery could not be rescheduled
---> System.AggregateException: One or more errors occurred. (The specified resource description is invalid. TrackingId:cda5544e-90e4-4818-97f9-4de3ee55aaad_G46, SystemTracker:**TOPIC**, Timestamp:2020-07-22T13:22:23) (BAM! <- MY ERROR)
---> Microsoft.Azure.ServiceBus.ServiceBusException: The specified resource description is invalid. TrackingId:cda5544e-90e4-4818-97f9-4de3ee55aaad_G46, SystemTracker:**TOPIC**, Timestamp:2020-07-22T13:22:23
---> System.ArgumentException: The specified resource description is invalid. TrackingId:cda5544e-90e4-4818-97f9-4de3ee55aaad_G46, SystemTracker:**TOPIC**, Timestamp:2020-07-22T13:22:23
I tried a different setup, more similar to the documentation:
busFactoryConfig.UseMessageScheduler(uri); //Uri is my sb endpoint, minus Endpoint=
This gets us a different error:
InvalidAudience: The authorization header contains a token with a wrong audience.
A quick read reveals this is something to do with how Azure uses the keys, and that it may be out of date. However, this is the same URI I'm using to connect to the bus successfully - all I've done is remove the Endpoint= so that it's a valid URI when constructing new Uri().
Does scheduled redelivery work with MT for Azure Service Bus? Am I missing something in configuration?
Any help would be appreciated.