How to retrieve messages from DLQ and resubmit them in ascending order based on EnqueuedTime

Beniamin Muresan 0 Reputation points
2023-06-15T15:24:52.8133333+00:00

Hello,

We are trying to build a mechanism that reads all the messages from a subscription deadletter queue and resubmit them to the parent topic in the same ordered that they were initially enqueued.
Is this possible without sessions? I was thinking to use the EnqueuedTime but I have the following problem:

  • RServiceBusReceiver.ReceiveMessagesAsync does not return the maximum number present in DLQ, so it needs to be called multiple times to eventually get all the messages. Because of this, it is not possible to build a collection and then order it ascending by EnqueuedTime. Not completing a message will leave the message in the queue, therefore the chances to be picked up again are high, ending up in a collection with duplicates, or with redundant calls to ReceiveMessagesAsync.

Do you have any suggestions for an ordered resubmit?

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
702 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,932 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yuvaraj Madheswaran 390 Reputation points
    2023-07-14T16:46:16.23+00:00

    Hello,

    Please find the example to process messages from dead letter queue as below,

    https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/servicebus/azure-messaging-servicebus/src/samples/java/com/azure/messaging/servicebus/DeadletterQueueSample.java

    Please let us know if it helps.

    Thanks!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.