gpt4 book ai didi

Azure服务总线-消息直接进入死信队列

转载 作者:行者123 更新时间:2023-12-05 00:13:07 24 4
gpt4 key购买 nike

我有以下代码将消息发送到总线:

var queueClient = new QueueClient(ServiceBusConnectionString, QueueName);

var message = new Message(poco.SerializeToBytes());

await queueClient.SendAsync(message);

但他们似乎直接进入死信消息计数:

enter image description here

我还创建了一个 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.

问题与以下事实有关:您从"new".NET 标准服务总线客户端发送消息,而 Function App v1 使用“旧”基于 BrokeredMessage 的客户端。并且它们在二进制级别上不兼容,请参阅 this issue .

在包含服务总线绑定(bind)的 Function App v2 准备就绪之前,您应该更好地使用旧的服务总线客户端来发送消息。如果您必须使用新客户端,请参阅上面链接的问题中的一些解决方法,例如this comment .

关于Azure服务总线-消息直接进入死信队列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49051829/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com