我的服务总线队列最近遇到了问题。随机消息(一个可以通过,另一个不能)被放置在死信队列中,并显示错误消息:
"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"
甚至在我的消费者有机会从队列接收消息之前,这种情况就会发生。
奇怪的是,当我通过 Service Bus Explorer 重新排队消息时,它会通过并被我的消费者成功接收和处理。
我使用相同版本的服务总线来发送和接收消息:
Azure.Messaging.ServiceBus, version: 7.2.1
我的消息是这样发送的:
await using var client = new ServiceBusClient(connString);
var sender = client.CreateSender(endpointName);
var message = new ServiceBusMessage(serializedMessage);
await sender.SendMessageAsync(message).ConfigureAwait(true);
最佳答案
因此,我现在针对所描述的问题的解决方案是,我对进入死信队列的消息实现了重试策略。该消息从 DLQ 克隆并再次添加到 ServiceBus 队列中,第二次没有任何问题,消息成功完成。我认为发生这种情况是因为 Azure 基础设施中可能存在一些奇怪的性能问题。但这种方法为我赢得了一些时间来进一步调查。
关于Azure 服务总线 - 随机反序列化问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69103153/