如何窥探死信 [英] How to peek the deadletter messages

查看:110
本文介绍了如何窥探死信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很难找到有关将所有消息放入死信队列并进行窥视的良好文档.

It is very hard to find some good documentation on getting all the messages in a deadletter queue and getting to take a peek at them.

我有一个Azure Servicebus队列,我所能找到的都是关于Azure Servicebus主题的.

I have an Azure Servicebus Queue and everything I can find is for Azure Servicebus Topics.

有人可以帮助我提供快速指南吗?

Can someone help me with a quick guide?

推荐答案

死信队列是将毒物消息移动到的辅助子队列.

Dead letter queue is a secondary sub-queue where the poison messages are moved to.

对于Azure Servicebus队列,DLQ的标准路径为queuePath/$DeadLetterQueue. 因此,您需要另一个queueClient来读取DLQ.

In case of Azure Servicebus Queue the standard path for DLQ is queuePath/$DeadLetterQueue. So you need to have another queueClient to read the DLQ.

然后您将在.NET客户端中执行类似的操作.

And you will do something like this in .NET clients.

string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
var client = QueueClient.CreateFromConnectionString(connectionString, "QueueName");

// do whatever regular queue reading activities

// this is for dead letter queue
var deadLetterClient = QueueClient.CreateFromConnectionString(connectionString, QueueClient.FormatDeadLetterPath(client.Path), ReceiveMode.ReceiveAndDelete);

BrokeredMessage receivedDeadLetterMessage;
while ((receivedDeadLetterMessage = deadLetterClient.Receive(TimeSpan.FromSeconds(10))) != null)
{
    Console.WriteLine(receivedDeadLetterMessage);
}

这篇关于如何窥探死信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆