Home > Back-end >  Messages in Azure Message Queue are going Straight to the Poison Message Queue
Messages in Azure Message Queue are going Straight to the Poison Message Queue

Time:04-03

[Hoping this might save someone some time.]

The code below stopped working when moving to the newer QueueClient class (in Azure.Storage.Queues) from the deprecated CloudQueue class (in Microsoft.Azure.Storage.Queue):

QueueClient queue = new QueueClient(accountConnectionString, "myQueuename");
queue.Create();
queue.SendMessage(msg);

Messages are being moved into the associated poison message queue, and I don't see any error messages in Azure's ApplicationInsights.

When I manually move the message in Azure Storage Explorer from the poison message queue back into the queue, it works!

CodePudding user response:

The CloudQueue class defaulted to using base64 encoding in the prior v11 library, whereas QueueClient does not!

To set base64 encoding, add a QueueClientOptions:

QueueClientOptions queueOptions = new() { MessageEncoding = QueueMessageEncoding.Base64 };
QueueClient queue = new QueueClient(accountConnectionString, "myQueuename", queueOptions);
queue.Create();
queue.SendMessage(msg);
  • Related