2

My DeadLetter queue in Microsoft Azure (for a topic) currently contains 60,000 records. I want to clear this but I can't seem to find any information on how to do this. I've tried using service bus explorer but it took a long time just trying to delete 1000 items.

Is it possible to do this in one statement, or do I have to delete the topic and re-create it.

dreza
  • 3,605
  • 7
  • 44
  • 55

1 Answers1

0
string connectionString = ConfigurationManager.AppSettings["connectionString"];    
 ServiceBusConnectionStringBuilder builder = new ServiceBusConnectionStringBuilder(connectionString);    
            MessagingFactory factory = MessagingFactory.CreateFromConnectionString(builder.ToString());    
SubscriptionClient deadletterClient = factory.CreateSubscriptionClient(yourtopicName, "yoursubscriptionName/$DeadLetterQueue");   
while(true)
            {    
                BrokeredMessage msg = deadletterClient.Receive();    
                if(msg != null)    
                {    
                    msg.Complete();    
                }    
                else     
                {    
                    break;    
                }        
}   
Amit
  • 167
  • 1
  • 2
  • 14
  • Let us suppose we have a topic name abc and has a subscription xyz.. And I need to access the dead letter queue messages of this (xyz) subscription. We can now create a subscription client by passing topic name and subscription name to createsubscriptionclient method.. Since we need to access the DLQ we are giving its path by adding /$Deadletterqueue to the subscription name..the DLQ messages can be accessed by calling receive method.. I just now saw I need to edit the code snippet written above while giving subscription name.. – Amit Feb 23 '17 at 19:15