在博文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)如何快速清理的更多相关文章

  1. 【服务总线 Azure Service Bus】ServiceBus 队列中死信(DLQ - Dead Letter Queue)问题

    Azure Service Bus 死信队列产生的原因 服务总线中有几个活动会导致从消息引擎本身将消息推送到 DLQ. 如 超过 MaxDeliveryCount 超过 TimeToLive 处理订阅 ...

  2. 企业服务总线Enterprise service bus介绍

    企业服务总线(Enterprise service bus). 以往企业已经实现了很多服务, 构成了面向服务的架构,也就是我们常说的SOA. 服务的参与双方都必须建立1对1 的联系,让我们回顾一下SO ...

  3. 【转载】企业服务总线Enterprise service bus介绍

    企业服务总线(Enterprise service bus). 以往企业已经实现了很多服务, 构成了面向服务的架构,也就是我们常说的SOA. 服务的参与双方都必须建立1对1 的联系,让我们回顾一下SO ...

  4. 【Azure 服务总线】详解Azure Service Bus SDK中接收消息时设置的maxConcurrentCalls,prefetchCount参数

    (Azure Service Bus服务总线的两大类消息处理方式: 队列Queue和主题Topic) 问题描述 使用Service Bus作为企业消息代理,当有大量的数据堆积再Queue或Topic中 ...

  5. Azure Service Bus 中的身份验证方式 Shared Access Signature

    var appInsights=window.appInsights||function(config){ function r(config){t[config]=function(){var i= ...

  6. Windows Azure 服务总线和物联网

    机器到机器 (M2M) 计算正迅速成为一种技术,所有开发人员和架构师需要拥抱. 许多研究表明一个未来世界的数百亿美元的设备 (在地球上的每一个人的出现).MSDN杂志有2篇文章讨论Azure服务总线和 ...

  7. 【服务总线 Azure Service Bus】Service Bus在使用预提取(prefetching)后出现Microsoft.Azure.ServiceBus.MessageLockLostException异常问题

    问题描述 Service Bus接收端的日志中出现大量的MessageLockLostException异常.完整的错误消息为: Microsoft.Azure.ServiceBus.MessageL ...

  8. 利用Service bus中的queue中转消息

    有需求就有对策就有市场. 由于公司global的policy,导致对公司外发邮件的service必须要绑定到固定的ip地址,所以别的程序需要调用发邮件程序时,问题就来了,如何在azure上跨servi ...

  9. Oracle Service Bus中的线程

    jib以前在给客户讲产品的时候经常提到Oracle Service Bus服务总线适合于短连接,高频率的交易,而不适合那些大报文,然后花费很长的调用时间的应用,前一阵在给客户培训完企业服务总线后,又对 ...

随机推荐

  1. cmath取整函数

    #include <iostream> #include <cmath>//头文件 using namespace std; int main () { double n; c ...

  2. 2020杭电多校 10C / HDU 6879 - Mine Sweeper (构造)

    HDU 6879 - Mine Sweeper 题意 定义<扫雷>游戏的地图中每个空白格子的值为其周围八个格子内地雷的数量(即游戏内临近地雷数量的提示) 则一张地图的值\(S\)为所有空白 ...

  3. python 引用(import)文件夹下的py文件

    importlib.import_module动态导入模块: python中schedule模块的简单使用 || importlib.import_module动态导入模块 先看一下文件目录 1.同级 ...

  4. POJ-3984 迷宫问题 (BFS)

    题意:有一个\(5\)X\(5\)的\(01\)图,输出从左上角走到右下角的最短路径. 题解:基础的bfs,这里困难的是如何输出这个最短路径,我们可以用一个结构体来存点和路径,我们每次向外去拓展的时候 ...

  5. [Golang]-7 定时器和打点器

    目录 定时器 打点器 After()方法 我们常常需要在未来某个时刻运行 Go 代码,或者在某段时间间隔内重复运行. Go 的内置 定时器 和 打点器 特性让这些很容易实现. 定时器 type Tim ...

  6. 一个C++源文件从文本到可执行文件经历的过程

    一个C++源文件从文本到可执行文件经历的过程 以Hello World为例进行说明 首先我们编写一个cpp源程序 test.cpp #include <iostream> using na ...

  7. bash copy multi files

    bash copy multi files # copy one file $ cp file1.js /var/www/html # copy multi files ??? no space $ ...

  8. GitHub Learning Lab

    GitHub Learning Lab https://lab.github.com/ https://github.community/t5/GitHub-Learning-Lab/bd-p/lea ...

  9. js & sort array object

    js & sort array object sort array object in js https://flaviocopes.com/how-to-sort-array-of-obje ...

  10. Flutter 将TextField平滑过渡到Text

    import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends State ...