I have created an azure service bus topic application which peek all messages in deadletter. Some specific messages(with particular messageid) which i peeked need to be removed from the deadletter queue. Please provide help for implementing this.
Asked
Active
Viewed 3,565 times
0
-
Can you show us what you've done for the moment ? – Thomas Feb 04 '16 at 20:03
3 Answers
3
By calling complete on the reference to the brokered message you receive from the dead letter queue you can remove it from the dead letter queue.

Aravind
- 4,125
- 1
- 28
- 39
-
@pilid if the answer is correct, like it seems to be, please mark it as the answer. – Nicolò Carandini Mar 05 '17 at 18:24
3
First if you need to know how to create a service bus topic and subscription:
To receive message from a subscription, you need to create a message receiver :
//Create the messaging factory
var messagingFactory = MessagingFactory.CreateFromConnectionString("ServiceBusConnectionString");
// Get the dead letter path
var deadLetterPath = SubscriptionClient.FormatDeadLetterPath("TopicPath", "subscriptionName");
// Get the message receiver for the deal letter queue.
var messageReceiver = messagingFactory.CreateMessageReceiver(deadLetterPath);
Then you can just listen for messages arriving:
// This is the list of ids that need to be delete
var messageIdsToDelete = new List<long>(...);
messageReceiver.OnMessage((message) =>
{
// Check if we have to delete the message
if (messageIdsToDelete.Contains(message.SequenceNumber))
{
// Complete and delete the message from the queue.
message.Complete();
}
}, new OnMessageOptions());

Thomas
- 24,234
- 6
- 81
- 125
0
This code helps you to delete a dead-letter message in Azure service bus.
MessageReceiver fromQueueClient = null;
MessagingFactory factory = MessagingFactory.CreateFromConnectionString(connectionString);
fromQueueClient = await factory.CreateMessageReceiverAsync(_entityName, ReceiveMode.PeekLock);
BrokeredMessage _message = await fromQueueClient.ReceiveAsync(SequenceNumber);
await _message.CompleteAsync();

Reshma Sulthan
- 531
- 5
- 5