Raju Rudru
Raju Rudru

Reputation: 1132

How to ensure ordered delivery of messages on a session enabled queue/subscription when dead lettering happens in Azure Service Bus

I am working on building an integration project which involves the usage of Azure Service Bus Topic subscriptions and an Azure Function app subscribing to the topic. My essential requirement is to ensure the updates related to a user(which can happen at different time intervals in a day) must be delivered in the same order of occurrence and perform parallel processing of the messages.

For Example, consider below updates:

  1. User1 made a payment
  2. User2 updated profile
  3. User2 made a payment
  4. User1 changed address
  5. User1 reported a dispute on the payment
  6. User2 reported a dispute on the payment

These three updates per User1 and User2 may happen at different times of the day but must be sent to the subscribing Function app in the same order. In the example, a dispute on a payment can not be sent before the payment update.

To achieve this I have chosen to implement Message Sessions on Service Bus. First I enable the session on the Service Bus queue/topic and set the user-id as session-id while publishing a message.

I know I can implement PeekLock behavior and client-side retries to recover from transient failures. Suppose, because of an issue (could be client-side or max delivery count exhausted) the message is moved to a dead lettering queue in Service Bus. I can create another Azure function to retry the dead-lettered messages.

But how do I ensure the messages are delivered in the same sequence if one message is dead-lettered? Are there any best practices to ensure I do auto retry of dead-lettered messages and at the same time deliver updates in the same order they are published into the queue?

Thanks in advance for your help.

Note: I did not find a similar question in stack overflow, hence posted this question. I find retry of dead-lettered queues but not in the case of session-enabled queues/topics.

Upvotes: 0

Views: 462

Answers (1)

Tiago Castilhos
Tiago Castilhos

Reputation: 21

I found this thread here that's very similar to your question: Sends all messages with the same sessionId to the dead letter queue on Azure Service Bus Queue

There's no mechanism from azure service bus to handle it, the "solution" is to peek messages from dead letter manually and verifying if there's any message from the given session.

Upvotes: 0

Related Questions