Reputation: 16219
below code works fine to read service bus queue deadletter but for topic even after changing path it it throwing exception path is not correct.
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)
{
Now I want to do the same for Service Bus Topic DeadLetter
So path should be - 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)
{
Getting exception path is not correct...
Upvotes: 1
Views: 1270
Reputation: 25994
Topics don't have dead-lettered queues, subscriptions do. What you need to use it SubscriptionClient.FormatDeadLetterPath(String, String) method, passing topic and subscription names.
Upvotes: 1