问题
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