【问题标题】:ServiceBusTrigger Message not able to read BrokeredMessages due to content type由于内容类型,ServiceBusTrigger 消息无法读取 BrokeredMessages
【发布时间】:2018-11-28 16:30:26
【问题描述】:

C# .NET Core Azure Functions v2; Microsoft.Azure.ServiceBus 3.2.0、Microsoft.Azure.WebJobs 3.0.2、Microsoft.Azure.WebJobs.Extensions.ServiceBus 3.0.1

我们收到使用旧 ServiceBus 包(WindowsAzure.ServiceBus、Microsoft.ServiceBus)发布的 BrokeredMessages,Content-Type: text/plain

我们在azure函数中使用ServiceBusTrigger来消费:

[ServiceBusTrigger("topic", "subscription", Connection = "appsetting")]Message message,

当尝试使用新包从主题中消费时

(microsoft.azure.servicebus) 我们遇到以下错误:

System.Private.CoreLib:执行函数时出现异常:Function1。 Microsoft.Azure.WebJobs.Host:异常绑定参数“消息”。 System.Private.CoreLib:无法将索引 60 处的字节 [99] 从指定的代码页转换为 Unicode。

即使我们尝试使用其他类型而不是 Message 也会出现此错误,例如 stringbyte[] 和自定义类型。

问题似乎是 Content-Type

内容类型:文本/纯文本

其他 BrokeredMessage 组合似乎工作正常(其中没有一个是空的 Content-Type); stream+none、stream+text/plain、string+none 和 string+text/plain;charset=unicode。

我们可能能够在我们的 webjobs 中绕过这个(未经测试),因为我们可以在运行时访问 MessageReceiver 或其他 ServiceBus 配置来处理这个问题,但是到目前为止,我们还没有找到任何解决方案或方法来处理这个 Azure作为框架的函数在我们进入函数之前会抛出一个错误。

有没有其他人遇到过这个错误?我目前的做法有问题吗?

我们无法控制消息的生成,因此我们无法轻易更改。

其他人有类似配置的不同问题:BrokeredMessage send and Message consumer in Azure Function v2

【问题讨论】:

标签: c# azure-functions servicebus azure-servicebus-topics


【解决方案1】:

您是否尝试过指定编码以及内容类型?喜欢:Content-Type: text/plain;charset=unicode

【讨论】:

  • 虽然这会起作用(就像使用任何其他已确认有效的 Content-Type 变体一样),但我无法控制消息生成,因此很遗憾我们无法指定字符集
猜你喜欢
  • 1970-01-01
  • 2017-11-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-12
  • 2018-11-19
  • 2021-09-06
相关资源
最近更新 更多