Reputation: 2332
I am following the nodejs examples here to retrieve messages sent to the dead letter queue. I was pushing dead letters to the Q in this manner:
await brokeredMessage.deadLetter({
deadletterReason: 'bad',
deadLetterErrorDescription: 'too bad, so sad.',
});
I do see the dead letter count is 2 in Azure. Whether these arrived as a result of my deadletter code above or whether some other mishap caused messages to be dead-lettered, I have 2 in the DLQ. However I can't retrieve them with:
const client = ns.createQueueClient(queueName);
const receiver = client.getReceiver();
const sender = client.getSender();
const messages = await receiver.receiveBatch(100);
if (messages.length > 0) {
for (let i = 0; i < messages.length; i += 1) { ... }
} else {
// I ALWAYS GET HERE.
}
What am I doing wrong? There are no errors. Why can't I read the DLQ and retrieve the 2 items there? Does the queue name change like it does for poison messages? I am using the same queuename while sending, deadlettering and trying to read the DLQ.
Upvotes: 1
Views: 845
Reputation: 333
Try using
const client = ns.CreateQueueClient(QueueClient.FormatDeadLetterPath(queueName));
since all your messages are in your dead-letter queue,you can receive the messages from the dead-letter path by creating a message receiver for the dead-letter end of the queue
Upvotes: 0
Reputation: 1331
I believe that you need to append /$DeadLetterQueue
to your queue name. So const deadLetterQueueName = queueName + "/$DeadLetterQueue";
See this GitHub issue here on the azure-sdk-for-node repo.
Upvotes: 2