azure - Azure 事件中心事件属性如何序列化?

标签 azure azure-eventhub

我要制作并发送EventData具有在 EventData.Properties 中设置的各种特定于应用程序的属性的对象字典。 Properties字典本身定义为 IDictionary<string, object>这意味着我可以传递任何数据类型作为值。

var eventData = new EventData(bytes);
eventData.Properties["Prop1"] = // string?
eventData.Properties["Prop2"] = // int?
eventData.Properties["Prop3"] = // DateTime?
eventData.Properties["Prop4"] = // Custom?

我实际上允许将哪些数据类型传递到 Properties字典?显然,这些数据需要以某种方式序列化,但文档没有提及任何相关内容。

最佳答案

跟进 Chris 的回答 - AMQP header 根据 AMQP 类型规范进行序列化 - http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html .

对于查看此答案的任何 Java 开发人员 - 您可以使用 Apache qpid 库来执行编码/解码操作。解码器类可以在这里找到 - https://qpid.apache.org/releases/qpid-proton-j-0.33.1/api/index.html .

EH 服务与编码无关,因此通过 Kafka 协议(protocol)读取的消费者需要手动解码 AMQP header 。 native EH 客户端将为您解码 header 。请参阅 - https://github.com/Azure/azure-event-hubs-for-kafka/issues/56 .

关于azure - Azure 事件中心事件属性如何序列化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56708294/

相关文章:

azure - 如何从 ADLS 将自定义数据帧写入 eventhub

azure - 不使用 TLS 加密将 AMQP 遥测发送到 Azure 事件中心

java - azure 事件中心 - 仅处理新消息

powershell - Azure PowerShell - 未将对象引用设置为对象的实例

Azure WebJobs : difference between Console. WriteLine 和 logger.WriteLine

json - Azureml Web 服务 - 如何从实验创建供移动应用程序使用的 Rest 服务?

wcf - aspNet兼容性启用="true"

python - 适用于 python 的 Azure eventhub 库

c# - 我们如何在没有存储容器名称、StorageAccountName 和 StorageAccountKey 这些信息的情况下从 Azure 事件中心接收事件

azure - 防止 Azure Live Metrics Stream 将每个轮询记录到队列