[英]Azure service bus | Re process dead letter messages back to queue | How to receive all messages from dead letter queue?
I want to integrate the processing of messages back to Queue using a Unique Identifier as user inputs.我想使用唯一标识符作为用户输入将消息处理集成回队列。 How to fetch all the messages from the dead letter in a single call instead of looping it multiple times?
如何在一次调用中从死信中获取所有消息,而不是多次循环?
var msRequestIdArg = MsRequestIds.Split('\n').Select(e => e.Trim()).ToList();
var msRootRequestArg = MsRootRequestIds.Split('\n').Select(e => e.Trim()).ToList();
var queueClient = QueueClient.CreateFromConnectionString(ServiceBusConnectionString, QueueName);
var factory = MessagingFactory.CreateFromConnectionString(ServiceBusConnectionString);
var deadLetterPath = QueueClient.FormatDeadLetterPath(QueueName);
var deadLetterQueueReceiver = factory.CreateMessageReceiver(deadLetterPath, ReceiveMode.PeekLock);
deadLetterQueueReceiver.PrefetchCount = 10;
var messageResponse = new List<Tuple<string, bool, string>>();
var counter = msRequestIdArg.Count + msRootRequestArg.Count;
while (counter > 0)
{
var brokeredMessage = await deadLetterQueueReceiver.ReceiveAsync().ConfigureAwait(false);
Short answer: you can't and should not.简短的回答:你不能也不应该。
Imagine you'd have hundreds of thousands, if not millions, of messages that need to be returned.想象一下,您将有数十万甚至数百万条消息需要返回。 Can you imagine the constraints on both the broker and the clients with this amount of messages that need to be transferred?
您能想象对于需要传输这么多消息的代理和客户端的限制吗? Failures are expected to happen, and with a very large number of messages, you'd be quickly finding yourself in a situation when a call such as this one would consistently fail, rendering your system helpless.
预计会发生故障,并且由于消息数量众多,您很快就会发现自己处于这样一种情况,即这样的呼叫会持续失败,从而使您的系统无能为力。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.