Search code examples
azurequeueazureservicebusservicebusazure-servicebus-queues

Azure Service Bus - random deserialization issues


I've been recently having problems with my Service Bus queue. Random messages (one can pass and the other not) are placed on the deadletter queue with the error message saying:

"DeadLetterReason": "Moved because of Unable to get Message content There was an error deserializing the object of type System.String. The input source is not correctly formatted."
"DeadLetterErrorDescription": "Des"

This happens even before my consumer has the chance to receive the message from the queue.

The weird part is that when I requeue the message through Service Bus Explorer it passes and is successfully received and handled by my consumer.

I am using the same version of Service Bus either for sending and receiving the messages:

Azure.Messaging.ServiceBus, version: 7.2.1

My message is being sent like this:

        await using var client = new ServiceBusClient(connString);
        var sender = client.CreateSender(endpointName);
        var message = new ServiceBusMessage(serializedMessage);
        await sender.SendMessageAsync(message).ConfigureAwait(true);

Solution

  • So the solution I have for now for the described issue is that I implemented a retry policy for the messages that land on the dead-letter queue. The message is cloned from the DLQ and added again to the ServiceBus queue and for the second time there is no problems and the message completes successfully. I suppose that this happens because of some weird performance issues I might have in the Azure infrastructure. But this approach bought me some time to investigate further.