Open roberino opened 6 years ago
There are multiple options to format that body in AMQP protocol including AmqpValue , or Data body. We use Data body within azure SDKs. It depends on how MuleSoft encodes the data while sending to service bus. Do you know if it is wrapped as AmqpValue or Data body within mulesoft connector? Also, could you share a sample repro?
Hi...I'm afraid I don't have further details regarding the mulesoft connector as a third-party has implemented this but...
...we've managed to work around this by using the GetBody Interop function as implemented in the example code below. What we're trying to ensure is that the behaviour is consistent regardless of the protocol as we have numerous message publishers and message subscribers.
Looking at the implementation of GetBody, it would seem in our case that the body of the message is being sent as an AmqpValue and not in the Data section (as our third party is sending the body as a JSON encoded string).
Currently, the dotnet service bus library does not expose the internal AMQP object model and the only way I can see to get the AmqpValue is via the MessageInteropExtensions which seems like it's intended for Data Contract serialized messages.
Are there plans to expose some of this in future?
Example workaround:
internal static byte[] GetBodyBytes(this Message message)
{
if (message.Body != null) return message.Body;
var msg = message.GetBody<object>()?.ToString();
return msg == null ? null : Encoding.UTF8.GetBytes(msg);
}
Yes. We do want to expose bare AmqpMessage to the user just to handle scenario like yours. But we haven't got to it yet, and don't have a proper timeline for that feature either.
Actual Behavior
Expected Behavior
Versions