gpt4 book ai didi

c# - 如何从服务总线主题死信队列中读取C#?

转载 作者:行者123 更新时间:2023-12-03 02:48:15 24 4
gpt4 key购买 nike

下面的代码可以很好地读取服务总线队列死信,但对于主题,即使在更改路径后,它抛出的异常路径也不正确。

string path= "QueueName";

MessagingFactory messageFactory = MessagingFactory.CreateFromConnectionString("ConnecitonString");

MessageReceiver deadletterReceiver = await messageFactory.CreateMessageReceiverAsync(QueueClient.FormatDeadLetterPath(path), ReceiveMode.PeekLock);

MessageSender sender = await messageFactory.CreateMessageSenderAsync(path);

BrokeredMessage deadLetter = await deadletterReceiver.ReceiveAsync(TimeSpan.Zero);
if (deadLetter != null)
{

现在我想对服务总线主题 DeadLetter 执行相同的操作所以路径应该是 - topicName/subscriptionName

 string path= "TopicName/SubscriptionName";

MessagingFactory messageFactory = MessagingFactory.CreateFromConnectionString("ConnecitonString");

MessageReceiver deadletterReceiver = await messageFactory.CreateMessageReceiverAsync(TopicClient.FormatDeadLetterPath(path), ReceiveMode.PeekLock);

MessageSender sender = await messageFactory.CreateMessageSenderAsync(path);

BrokeredMessage deadLetter = await deadletterReceiver.ReceiveAsync(TimeSpan.Zero);
if (deadLetter != null)
{

获取异常路径不正确...

最佳答案

主题没有死信队列,而订阅有。使用它需要什么SubscriptionClient.FormatDeadLetterPath(String, String)方法,传递主题和订阅名称。

关于c# - 如何从服务总线主题死信队列中读取C#?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57554831/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com