How to use the MessageReceiver.Receive method by sequenceNumber on ServiceBus

后端 未结 2 1093
南笙
南笙 2021-01-13 03:07

I\'m trying to resubmit a message from a deadletter queue.

I am can replay a message on a dead letter queue, thats fine. The problem is when I want to now delete thi

2条回答
  •  心在旅途
    2021-01-13 03:52

    After creating receiver you can politely start receiving all messages (without being picky) till you encounter message with your SequenceNumber, call Complete() on the message and stop iterating the queue. i.e

            while (true)
            {
                BrokeredMessage message = receiver.Receive();
                if (message.SequenceNumber == sequenceNumber)
                {
                    message.Complete();
                    break;
                }
            }
    

    Without completing message it remains in the queue and that's what you want (at least in .NET 4.5. Worth to note that if your Sequence Number is not found Receiver will loop the queue indefinitely.

提交回复
热议问题