如何删除上的Azure服务总线主题的死信消息 [英] How do I delete a DeadLetter message on an Azure Service Bus Topic
问题描述
我写一张code的,这将使我们能够:
- 查看存在的Azure的服务总线主题(PEEK) 内的所有一纸空文邮件的列表
- 修正,并送他们回到正题
- 从死信队列时重新发送删除它们。
我有与该第一2分没有问题;使用皮克接收模式我可以显示邮件的列表,我们可以编辑和重新发送,没有问题。
问题是当我想要真正删除死信队列中的消息。
我们如何做到这一点对消息级别的消息?我们可能只需要删除居住在死信队列中的消息2,保持他人在稍后阶段审查。是否调用 .Complete()
在死信队列中的消息,像它在主订阅有去除呢?
有关参考;这里是我们code用于获取 SubscriptionClient
为死信队列:
私人SubscriptionClient GetOrCreateSubscriptionClient(字符串的connectionString)
{
如果(!NamespaceManager.TopicExists(_topicName))
{
NamespaceManager.CreateTopic(新TopicDescription(_topicName)
{
MaxSizeInMegabytes = 5120,
DefaultMessageTimeToLive = TimeSpan.FromSeconds(DEFAULT_LOCK_DURATION_IN_SECONDS)
});
} 如果(!NamespaceManager.SubscriptionExists(_topicName,_subscriptionName))
{
NamespaceManager.CreateSubscription(_topicName,_subscriptionName);
} VAR deadLetterPath = SubscriptionClient.FormatDeadLetterPath(_topicName,_subscriptionName); VAR的客户= SubscriptionClient.CreateFromConnectionString(
的connectionString,deadLetterPath,_subscriptionName,ReceiveMode.PeekLock); 返回客户端;}
是,号召完整的上,参照从死信收到撮合消息队列将死信队列中删除。
I'm writing a piece of code which will allow us to:
- View a list of all dead letter messages that exist within an Azure Service Bus Topic (Peek)
- Fix and send them back to the Topic
- Delete them from the dead letter queue upon resending.
I have no issues with the first 2 points; using the Peek receive mode I can show a list of messages and we can edit and resend with no issues.
The problem comes when I want to actually delete the message from the dead letter queue.
How do we do this on a message by message level? We may only want to delete 2 of the messages residing in the dead letter queue and keep the others for reviewing at a later stage. Does calling .Complete()
on a message in the dead letter queue remove it like it does in the main subscription?
For reference; here is our code for getting the SubscriptionClient
for the dead letter queue:
private SubscriptionClient GetOrCreateSubscriptionClient(string connectionString)
{
if (!NamespaceManager.TopicExists(_topicName))
{
NamespaceManager.CreateTopic(new TopicDescription(_topicName)
{
MaxSizeInMegabytes = 5120,
DefaultMessageTimeToLive = TimeSpan.FromSeconds(DEFAULT_LOCK_DURATION_IN_SECONDS)
});
}
if (!NamespaceManager.SubscriptionExists(_topicName, _subscriptionName))
{
NamespaceManager.CreateSubscription(_topicName, _subscriptionName);
}
var deadLetterPath = SubscriptionClient.FormatDeadLetterPath(_topicName, _subscriptionName);
var client = SubscriptionClient.CreateFromConnectionString(
connectionString, deadLetterPath, _subscriptionName, ReceiveMode.PeekLock);
return client;
}
Yes, calling complete on the reference to the brokered message you receive from the dead letter queue will remove it from the dead letter queue.
这篇关于如何删除上的Azure服务总线主题的死信消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!