Search code examples
azure-functionsmasstransit

MassTranist Azure Service Bus in Isolated Mode Unable to get deliveryCount attribute of the context


Why is it that I can see the DeliveryCount when I investigate the ReceiveContext of my MassTransit object but I cannot pull that in as a variable?

I have tried looking at GetRetryAttempt(), GetRetryCount(), and GetRedeliveryCount() but these ALL return zero everytime.

In the photo, I would assume I would get 3 or 4 based on the call I made. I have also tried to look in the header for MT-Fault-RetryCount and this returns null. It seems that MassTransit is all in memory but the message does have access to the correct number it's just not part of the MassTransit ReceiveContext object - even though I SEE it there!


Solution

  • That works, but you should be using the payload methods:

    context.TryGetPayload<ServiceBusMessageContext>(out var messageContext)
        ? messageContext.DeliveryCount
        : default;