Azure Service Bus Brokered Message GetBody() deserialization

僤鯓⒐⒋嵵緔 提交于 2019-12-12 17:21:25

问题


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?

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?


回答1:


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.



来源:https://stackoverflow.com/questions/43420248/azure-service-bus-brokered-message-getbody-deserialization

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!