Azure 服务总线 - 消息直接进入死信队列
Azure service bus - message going straight to dead letter queue
我有以下代码向总线发送消息:
var queueClient = new QueueClient(ServiceBusConnectionString, QueueName);
var message = new Message(poco.SerializeToBytes());
await queueClient.SendAsync(message);
但他们似乎直接进入死信消息计数:
我还创建了一个 Azure 函数来接收消息:
[FunctionName("ServiceBusFunction")]
public static void Run([ServiceBusTrigger("schedule", AccessRights.Listen, Connection = "ServiceBusConnection")]byte[] myQueueItem, TraceWriter log)
{
log.Info($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
}
当我关闭该功能时,消息在我创建该功能之前进入了活动消息计数。我已经在本地尝试了 运行 函数,但没有命中该函数。我觉得我在从函数中获取总线上的消息方面缺少一些基本的东西?
如果您查看 Function App 日志,您可能会看到类似
的错误
Exception binding parameter 'myQueueItem'. Microsoft.Azure.WebJobs.ServiceBus: The BrokeredMessage with ContentType 'null' failed to deserialize to a byte[] with the message: 'There was an error deserializing the object of type System.Byte[]. The input source is not correctly formatted.'. System.Runtime.Serialization: There was an error deserializing the object of type System.Byte[]. The input source is not correctly formatted. System.Runtime.Serialization: The input source is not correctly formatted.
2018-03-01T15:14:41.578
Function App 尝试处理您的消息 10 次(默认),然后使用
将其放入 DLQ
Message could not be consumed after 10 delivery attempts.
问题与以下事实有关:您从 "the new" .NET Standard Service Bus 客户端发送消息,而 Function App v1 使用的是基于 "the old" BrokeredMessage
的客户端.而且它们在二进制级别上不兼容,请参阅 this issue。
在包含服务总线绑定的 Function App v2 准备就绪之前,您最好使用旧的服务总线客户端发送消息。如果您必须使用新客户端,请参阅上面链接的问题中的一些解决方法,例如this comment.
我有以下代码向总线发送消息:
var queueClient = new QueueClient(ServiceBusConnectionString, QueueName);
var message = new Message(poco.SerializeToBytes());
await queueClient.SendAsync(message);
但他们似乎直接进入死信消息计数:
我还创建了一个 Azure 函数来接收消息:
[FunctionName("ServiceBusFunction")]
public static void Run([ServiceBusTrigger("schedule", AccessRights.Listen, Connection = "ServiceBusConnection")]byte[] myQueueItem, TraceWriter log)
{
log.Info($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
}
当我关闭该功能时,消息在我创建该功能之前进入了活动消息计数。我已经在本地尝试了 运行 函数,但没有命中该函数。我觉得我在从函数中获取总线上的消息方面缺少一些基本的东西?
如果您查看 Function App 日志,您可能会看到类似
的错误Exception binding parameter 'myQueueItem'. Microsoft.Azure.WebJobs.ServiceBus: The BrokeredMessage with ContentType 'null' failed to deserialize to a byte[] with the message: 'There was an error deserializing the object of type System.Byte[]. The input source is not correctly formatted.'. System.Runtime.Serialization: There was an error deserializing the object of type System.Byte[]. The input source is not correctly formatted. System.Runtime.Serialization: The input source is not correctly formatted. 2018-03-01T15:14:41.578
Function App 尝试处理您的消息 10 次(默认),然后使用
将其放入 DLQMessage could not be consumed after 10 delivery attempts.
问题与以下事实有关:您从 "the new" .NET Standard Service Bus 客户端发送消息,而 Function App v1 使用的是基于 "the old" BrokeredMessage
的客户端.而且它们在二进制级别上不兼容,请参阅 this issue。
在包含服务总线绑定的 Function App v2 准备就绪之前,您最好使用旧的服务总线客户端发送消息。如果您必须使用新客户端,请参阅上面链接的问题中的一些解决方法,例如this comment.