0

I am trying to delete messages from the dead-letter queue using this code:

QueueDescription qd = _queueManager.GetQueue(queueID);
QueueClient qc = _senderFactory.CreateQueueClient(queueID, ReceiveMode.ReceiveAndDelete);

received = qc.ReceiveBatch(deadMessageCount);
while (received != null && received.Count<BrokeredMessage>() > 0)
  received = qc.ReceiveBatch(deadMessageCount); // just in case

And keep getting:

The remote server returned an error: (400) Bad Request. The specified HTTP verb (GET) is not valid. TrackingId:104cc11d-21b5-440c-adde-e9ce9afb0603_G25,TimeStamp:1/24/2015 8:44:10 AM

What is wrong here?

Vadim Berman
  • 1,932
  • 1
  • 20
  • 39

2 Answers2

1

I ran into this same problem trying to get the count from the dead letter queue. It looks like the deadletterqueue doesn't allow you to get a count directly, you get it from the MessageCountDetails of the normal Queue.

Doesn't Work

NamespaceManager nsmgr = Microsoft.ServiceBus.NamespaceManager
    .CreateFromConnectionString(connectionString);
return  nsmgr.GetQueue(QueueClient.FormatDeadLetterPath(QueueName))
    .MessageCountDetails.DeadLetterMessageCount;

Does Work

return nsmgr.GetQueue(QueueName).MessageCountDetails.DeadLetterMessageCount;

Remember to perform operations on the deadletterqueue you still need to specify the correct p it in the queue client.

QueueClient.CreateFromConnectionString(connectionString,
    QueueClient.FormatDeadLetterPath(QueueName));
YakovL
  • 7,557
  • 12
  • 62
  • 102
0

This line is to blame: QueueDescription qd = _queueManager.GetQueue(queueID); because you can't get a dead-letter queue. You have to get the queue itself and then use the format method. Duh!

Vadim Berman
  • 1,932
  • 1
  • 20
  • 39