【Azure 服务总线】Azure Service Bus中私信(DLQ - Dead Letter Queue)如何快速清理
在博文ServiceBus 队列中死信(DLQ - Dead Letter Queue)问题一文中,介绍了服务总线产生私信的原因及可以通过代码的方式来清楚私信队列中的消息,避免长期占用空间(因为私信中的消息不会自动清理)

当前,我们也可以从Azure门户中查看到当前DLQ的数量,所占空间及进入DLQ的原因

问题描述
在使用Azure Service Bus过程中,随着时间的累积,当死信中存积了大量的消息时,如何快速的清理掉这些消息呢?
解决办法
使用Azure官方提供的工具 Service Bus Explorer。 连接到当前的Service Bus,通过选择Receive and Delete操作来获取并从Service Bus服务端中删除消息。
1) 下载Service Bus Explorer,解压文件后,双击ServiceBusExplorer.exe
2) 连接到Service Bus中并查看死信消息

3) Receive and Delete: 数据获取消息的数量,然后再Receive Mode中选择Receive and Delete

附录:另一种方式是通过代码来处理死信消息
如需要通过程序的方式获取死信队列中的消息,获取消息的方式和正常队列一样,把queueName变为死信队列的路径,通过QueueClient.FormatDeadLetterPath(queueName)方式获取

附上.NET伪代码:
static string queueName = "<QUEUE NAME>/$deadletterqueue";
static async Task ReceiveMessagesAsync()
{
await using (ServiceBusClient client = new ServiceBusClient(connectionString))
{
// create a processor that we can use to process the messages
ServiceBusProcessor processor = client.CreateProcessor(queueName, new ServiceBusProcessorOptions());
// add handler to process messages
processor.ProcessMessageAsync += MessageHandler;
// add handler to process any errors
processor.ProcessErrorAsync += ErrorHandler;
// start processing
await processor.StartProcessingAsync();
Console.WriteLine("Wait for a minute and then press any key to end the processing");
Console.ReadKey();
// stop processing
Console.WriteLine("\nStopping the receiver...");
await processor.StopProcessingAsync();
Console.WriteLine("Stopped receiving messages");
}
}
参考资料
从队列接收消息: https://docs.azure.cn/zh-cn/service-bus-messaging/service-bus-dotnet-get-started-with-queues#receive-messages-from-a-queue
Azure Service Bus 死信队列产生的原因: https://www.cnblogs.com/lulight/p/13652828.html
Azure Service Bus Explorer: https://github.com/paolosalvatori/ServiceBusExplorer/releases
【Azure 服务总线】Azure Service Bus中私信(DLQ - Dead Letter Queue)如何快速清理的更多相关文章
- 【服务总线 Azure Service Bus】ServiceBus 队列中死信(DLQ - Dead Letter Queue)问题
Azure Service Bus 死信队列产生的原因 服务总线中有几个活动会导致从消息引擎本身将消息推送到 DLQ. 如 超过 MaxDeliveryCount 超过 TimeToLive 处理订阅 ...
- 企业服务总线Enterprise service bus介绍
企业服务总线(Enterprise service bus). 以往企业已经实现了很多服务, 构成了面向服务的架构,也就是我们常说的SOA. 服务的参与双方都必须建立1对1 的联系,让我们回顾一下SO ...
- 【转载】企业服务总线Enterprise service bus介绍
企业服务总线(Enterprise service bus). 以往企业已经实现了很多服务, 构成了面向服务的架构,也就是我们常说的SOA. 服务的参与双方都必须建立1对1 的联系,让我们回顾一下SO ...
- 【Azure 服务总线】详解Azure Service Bus SDK中接收消息时设置的maxConcurrentCalls,prefetchCount参数
(Azure Service Bus服务总线的两大类消息处理方式: 队列Queue和主题Topic) 问题描述 使用Service Bus作为企业消息代理,当有大量的数据堆积再Queue或Topic中 ...
- Azure Service Bus 中的身份验证方式 Shared Access Signature
var appInsights=window.appInsights||function(config){ function r(config){t[config]=function(){var i= ...
- Windows Azure 服务总线和物联网
机器到机器 (M2M) 计算正迅速成为一种技术,所有开发人员和架构师需要拥抱. 许多研究表明一个未来世界的数百亿美元的设备 (在地球上的每一个人的出现).MSDN杂志有2篇文章讨论Azure服务总线和 ...
- 【服务总线 Azure Service Bus】Service Bus在使用预提取(prefetching)后出现Microsoft.Azure.ServiceBus.MessageLockLostException异常问题
问题描述 Service Bus接收端的日志中出现大量的MessageLockLostException异常.完整的错误消息为: Microsoft.Azure.ServiceBus.MessageL ...
- 利用Service bus中的queue中转消息
有需求就有对策就有市场. 由于公司global的policy,导致对公司外发邮件的service必须要绑定到固定的ip地址,所以别的程序需要调用发邮件程序时,问题就来了,如何在azure上跨servi ...
- Oracle Service Bus中的线程
jib以前在给客户讲产品的时候经常提到Oracle Service Bus服务总线适合于短连接,高频率的交易,而不适合那些大报文,然后花费很长的调用时间的应用,前一阵在给客户培训完企业服务总线后,又对 ...
随机推荐
- Educational Codeforces Round 88 (Rated for Div. 2) E. Modular Stability(数论)
题目链接:https://codeforces.com/contest/1359/problem/E 题意 有一大小为 $k$ 的数组,每个元素的值在 $[1,n]$ 间,若元素间两两不等,问有多少数 ...
- Codeforces Round #307 (Div. 2) B. ZgukistringZ
Professor GukiZ doesn't accept string as they are. He likes to swap some letters in string to obtain ...
- 洛谷P1144-最短路计数-最短路变形
洛谷P1144-最短路计数 题目描述: 给出一个\(N\)个顶点\(M\)条边的无向无权图,顶点编号为\(1-N\).问从顶点\(1\)开始,到其他每个点的最短路有几条. 思路: \(Dijkstra ...
- Redis 主从复制(Replication)
为了保证服务的可用性,现代数据库都提供了复制功能,同时在多个进程中维护一致的数据状态. Redis 支持一主多从的复制架构,该功能被简化成了一条 SLAVEOF 命令,下面通过条命令来解析 Redis ...
- matplotlib 图标显示中文
matplotlib 显示中文 Method_1: # 添上: plt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签 plt.rcPara ...
- UIKit and SwiftUI
UIKit and SwiftUI Live Preview Try Again or Resume refs xgqfrms 2012-2020 www.cnblogs.com 发布文章使用:只允许 ...
- js logical operation all in one
js logical operation all in one 逻辑运算 Logical AND (&&) Logical AND assignment (&&=) L ...
- HTML5 in depth
HTML5 in depth Content Models Web Storage web storage 存储用户信息, 替代 cookies LocalStorage SessionStorage ...
- Azure 信用卡扣款 1 美元 & Azure 中国客服
Azure 信用卡扣款 1 美元 & azure 中国客服 Azure 免费帐户常见问题 https://azure.microsoft.com/zh-cn/free/free-account ...
- c++ winapi 让目标程序(target)调用当前程序(local)的函数
GameCheat 如果你的目标程序是x86/x64, 那么当前程序也需要编译为x84/x64 #include <iostream> #include <string> #i ...