I am sending messages to ASB using WCF NetMessaging. The message can contain any number of custom data contracts.
I have a Service Fabric stateless service with a custom listener for ASB delivering messages pushed onto the queue. All examples I’ve seen are able to only handle a single type of message (seems most guidance is to serializable to JSON but that’s not what I need to do here). I want the subscriber to the queue be able to handle a number of messages (any message sent to any action of the service).
I am able to add the Action to the BrokeredMessage.Properties so I know where to send it. The problem is I haven’t figured out how deserialize the message body in any way that works.
I can read it from a stream and get it to a string, but can’t do this: var myDTO = message.GetBody(); That throws serialization exceptions. I’ve also tried a variant of that passing in a DataContractSerializer - even though I think that is the default.
Furthermore, what I really need is a way to do this without knowing the type of data in the body - I could, conceivably, add more message.Properties for the types serialized in the body but I figure there has to be a direct way to do it using only the data in the body - after all WCF and similar techs do this with ease. But how?
Thanks for any help, Will