Azure Service Bus代理消息GetBody()反序列化 [英] Azure Service Bus Brokered Message GetBody() deserialization

查看:52
本文介绍了Azure Service Bus代理消息GetBody()反序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我将消息发送到服务总线队列并且消息的主体是自定义类,则将其称为CustomerInfo,如果发送消息的应用程序和接收到消息的应用程序如何处理消息并反序列化消息主体这些消息不共享一个称为CustomerInfo的通用类?

If I send a message to a service bus queue and the body of the message is a custom class, lets call it CustomerInfo, how do I process that message and deserialize the Message body if the application sending the message and the application receiving the messages do not share a common class called CustomerInfo?

我不是在寻找代码,而是在如何解决每个应用程序中CustomerInfo类的不同命名空间的答案.如果在收到消息并尝试使用GetBody获取消息正文时,没有在每个应用程序中使用DataContract命名空间属性在CustomerInfo类上指定匹配的命名空间,则由于命名空间的不同,将出现错误.只是在每个类的DataContract属性上指定相同的名称空间是正确的方法吗?

I am not looking for the code but rather an answer to how to address the different namespaces for the CustomerInfo class within each application. If I don't specify a matching namespace on the CustomerInfo class using the DataContract namespace property within each application when I receive the message and try to get the message body using GetBody I get an error because of the differing namespaces. Is just specifying the same namespace on each classes DataContract attribute the correct way to do it?

推荐答案

如果将自定义类序列化为JSON,这不是问题.反序列化时,重要的是要反序列化的类具有与序列化的原始类完全相同的属性.实际上,只要属性匹配,就可以序列化.NET POCO并反序列化为Java类.

If you serialize your custom class to JSON, this isn't an issue. When deserializing, the important thing is that the class you're deserializing to has the exact same properties as the original class that was serialized. In fact, you could serialize a .NET POCO and deserialize to a Java class as long as the properties matched.

这篇关于Azure Service Bus代理消息GetBody()反序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆