chris
chris

Reputation: 83

How to create behavior on delayed retry?

We are using an NSB8 endpoint which sends commands from a service that uses deterministic message IDs on ASB (that is for a given business ID it will always use the same message ID - this is good because it offers free deduplication)

We are currently using SendOptions.CustomizeNativeMessage() to support using the same deterministic ID scheme while sending a message, however on delayed retry where the endpoint errors we want to change the message id.

Is there any way we can create a behavior to set the native MessageID property on the native ASB message to an ID of our choosing on delayed retry? IRecoverabilityContext doesn't appear to have anything that I can hook into.

Any help would be appreciated.

Upvotes: 0

Views: 38

Answers (2)

Sean Feldman
Sean Feldman

Reputation: 25994

NServiceBus is a middleware framework. Like any other middleware framework, it's opinionated and leverages native features that have to align with the abstractions it provides. One of the abstractions is what a native Azure Service Bus service doesn't support—delayed retries. While there are immediate retries in the form of re-deliveries, the delayed retries feature doesn't exist yet. When it is added, and you can up-vote the feature request here to let the team know it's needed, then NServiceBus can provide the best of both worlds: delayed retries and native duplicate detection. Until then, NServiceBus has to ensure that the message ID is a random value to ensure its delayed retries abstraction is working correctly.

Upvotes: 0

Dennis van der Stelt
Dennis van der Stelt

Reputation: 2178

this is good because it offers free deduplication

And at the same time could hide more and cause even more damage. But ¯_(ツ)_/¯

IRecoverabilityContext doesn't appear to have anything that I can hook into.

Not sure what you mean with "hook into", but there's context.FailedMessage.Headers isn't there? I'm assuming it works for the message identifier, but I'm not 100% sure, because you should (almost) never ever, ever change the MessageId.

We offer support at Particular Software for customers via [email protected] and on our website. It's often better to use those, as it allows for follow-up questions and more.

Upvotes: 0

Related Questions