I have an Azure Service Bus consumer targeting .NET. The consumer uses Microsoft.ServiceBus.Messaging.BrokeredMessage
to deserialize and handle the message:
BrokeredMessage message = ...;
var json = message.GetBody<string>();
This works great when using BrokeredMessage
on the publisher side:
var msg = new BrokeredMessage(json);
await _bus.SendAsync(msg);
Now, I'm porting the publisher to .NET Core and switching to using the newer type Microsoft.Azure.ServiceBus.Message
:
var msg = new Message(Encoding.UTF8.GetBytes(json));
msg.ContentType = "application/json;charset=utf-8";
When doing this, my consumer fails with the following error:
There was an error deserializing the object of type System.String. The input source is not correctly formatted.
Is it possible to produce messages using Message
and consume it using BrokeredMessage
?