为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

C#
海绵宝宝撒 2023-09-09 17:26:24
下面的代码可以很好地读取服务总线队列死信,但对于主题,即使在更改路径后,它抛出的异常路径也不正确。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){现在我想对服务总线主题死信做同样的事情所以路径应该是 -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)    {获取异常路径不正确...
查看完整描述

1 回答

?
慕后森

TA贡献1802条经验 获得超5个赞

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



查看完整回答
反对 回复 2023-09-09
  • 1 回答
  • 0 关注
  • 80 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信