0

デッドレターキュー内のすべてのメッセージを取得し、それらを覗き込むことについては、いくつかの良い文書を見つけるのは非常に難しいです。私はAzureのサービスバス待ち行列を持っています。私が見つけることができるものはサービスバストピックです...誰かが簡単なガイドで私を助けることができますか?デッドレターメッセージを覗く方法

答えて

3

デッドレターキューは、ポイズンメッセージを移動するセカンダリサブキューです。 空白のサービスバスキューの場合、DLQの標準パスはqueuePath/$ DeadLetterQueueです。 このDLQを読むには、別のキューを用意する必要があります。

そして、あなたは.netクライアントでこれを行うでしょう。ここで

string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString"); 
QueueClient Client = QueueClient.CreateFromConnectionString(connectionString, "QueueName"); 
// do whatever regular queue reading activities 

// this is for dead letter queue 
    QueueClient deadLetterClient = QueueClient.CreateFromConnectionString(connectionString, QueueClient.FormatDeadLetterPath(Client.Path), ReceiveMode.ReceiveAndDelete); 
      BrokeredMessage receivedDeadLetterMessage; 

      while ((receivedDeadLetterMessage = deadLetterClient.Receive(TimeSpan.FromSeconds(10))) != null) 
      { 
       Console.WriteLine(receivedDeadLetterMessage); 
      } 
+0

しかし、私は本当にtopicPathが何であるか見当もつかない?これはキューでありトピックではないので –

+0

申し訳ありません。キュークライアントでコードを更新しました。何らかの理由で私はあなたがトピックとサブを求めたと思った。 – Aravind

+0

それはwhileループに来るときうーん、これは私に次のエラーを与える:40103:無効な認証トークン署名、 おかげしかし は型「System.UnauthorizedAccessException」の未処理の例外は 追加情報Microsoft.ServiceBus.dllに発生しました! –

0
string connectionString = ConfigurationManager.AppSettings["connectionString"];  
string queueName = ConfigurationManager.AppSettings["queueName"];  
ServiceBusConnectionStringBuilder builder = new ServiceBusConnectionStringBuilder(connectionString);  
MessagingFactory factory = MessagingFactory.CreateFromConnectionString(builder.ToString());  
var client = QueueClient.CreateFromConnectionString(connectionString, queueName);  
string deadLetterQueuePath = QueueClient.FormatDeadLetterPath(queueName);  
QueueClient deadletterQueueClient = factory.CreateQueueClient(deadLetterQueuePath);  
while (true)  
{  
     BrokeredMessage brokeredMessage = deadletterQueueClient.Receive();  
     // Your Logic  
} 
0

あなたがかいま見を使用不能キュー内のすべてのメッセージの一覧を取得する方法の例です:

public async Task<IEnumerable<BrokeredMessage>> GetDeadLetterMessagesAsync(string connectionString, 
    string queueName) 
{ 
    var queue = QueueClient.CreateFromConnectionString(connectionString, QueueClient.FormatDeadLetterPath(queueName)); 
    var messageList = new List<BrokeredMessage>(); 
    BrokeredMessage message; 
    do 
    { 
     message = await queue.PeekAsync(); 
     if (message != null) 
     { 
      messageList.Add(message); 
     } 
    } while (message != null); 
    return messageList; 
} 
関連する問題