如何在azureservicebus中窥视并删除Deadletter中的消息 [英] how to peek and delete a message from deadletter in azureservicebus

本文介绍了如何在azureservicebus中窥视并删除Deadletter中的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个Azure Service Bus主题应用程序,该应用程序可以查看 deadletter 中的所有消息.我偷看过的某些特定消息(具有特定messageid)需要从死信队列中删除.请提供实施此帮助.

I have created an azure service bus topic application which peek all messages in deadletter. Some specific messages(with particular messageid) which i peeked need to be removed from the deadletter queue. Please provide help for implementing this.

推荐答案

首先,如果您需要了解如何创建服务总线主题和订阅:

First if you need to know how to create a service bus topic and subscription:

要接收来自订阅的消息,您需要创建一个消息接收者:

To receive message from a subscription, you need to create a message receiver :

//Create the messaging factory
var messagingFactory = MessagingFactory.CreateFromConnectionString("ServiceBusConnectionString");

// Get the dead letter path
var deadLetterPath = SubscriptionClient.FormatDeadLetterPath("TopicPath", "subscriptionName");

// Get the message receiver for the deal letter queue.
var messageReceiver = messagingFactory.CreateMessageReceiver(deadLetterPath);

然后,您可以只听收到的消息:

Then you can just listen for messages arriving:

// This is the list of ids that need to be delete
var messageIdsToDelete = new List<long>(...);
messageReceiver.OnMessage((message) =>
{
    // Check if we have to delete the message
    if (messageIdsToDelete.Contains(message.SequenceNumber))
    {
        // Complete and delete the message from the queue.
        message.Complete();
    }

}, new OnMessageOptions());

这篇关于如何在azureservicebus中窥视并删除Deadletter中的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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