-
Notifications
You must be signed in to change notification settings - Fork 120
Unable to send "pure" body content #138
Comments
@justdmitry - From a quick glance I notice the following: If I change the Here is the change: public static async Task SendLegacy(MemoryStream stream)
{
var msg = new BrokeredMessage(stream.ToArray())
{
MessageId = Guid.NewGuid().ToString(),
Label = "WindowsAzure.ServiceBus",
}; And here is the result:
I believe this has something to do with the serializer in the old client, so we will need to do some further investigation. Usually this isn't the right place for "old client" issues, but this will certainly be relevant to users of the new library as well. Thanks for the awesome repro! |
@jtaubensee yes, old clients may be upgraded to send messages, "identical" to new "format". But it's not good "compatibility" point - ask to upgrade all parties to new message transport format... Also, what about receiving "pure byte stream" messages... I updated my demoapp and found that Also, if we look at other platforms/languages - are they always be able to deserialize "base64 binary by Microsoft", is this open format? So I'm back to my original question - its it really needed to perform serialization on "simple" byte sequence? |
We've been bitten by this. To me, it's looking as though an AmqpValueMessage is being created for the byte[], and the Amqp library is using it's own encoding (probably ArrayEncoding or BinaryEncoding which is decorating the content. It has broken our .NET 4.6 clients (including our Azure Functions, which would deserialize to our message types for us!), which we've fixed by doing something like:
...and then deserializing from messageContentStr, which now has the nasties removed. I understand the desire for the Message class to only use byte[] for holding the data, but if brokeredMessage.GetBody<byte[]>() on the client side doesn't mirror the byte[] that the sender added to the Message, then this feels a bit off to me... |
+1 for being able to construct a new Message with a Stream that isn't manipulated via serialization. In other words, it should behave like the full framework client. |
+1 for being able to construct a new Message with a Stream that isn't manipulated via serialization. In other words, it should behave like the full framework client to support interop. I've been "fixing" previous code to support solutions working with new Microsoft.Azure.ServiceBus code for days now. If we think about interop we need at the very least to provide visible guidance so this doesn't pop-up as a surprise. |
For those that are trying to remove the extra chars from existing messages. Here is the code used in the GetBody method.
|
Twitter conversation about old/new client issues by @MisterJames |
Should be labeled as a bug. |
On my side, I'm not sure that I have a way to help coach Azure Functions into proper deserialization, which happens during parameter binding, before my code is executed. The message won't even convert to I am using
To note, I've tried wrapping the message in an anon object as the Azure Functions bit was complaining about not finding the The Azure Function itself has a method with the following signature:
The Function does not execute (first line of logging is not executed) as binding fails with the message below. You can see above that I've also tried to deserialize to a POCO. Here's the exception that is thrown during binding.
|
Changing Message.Body to ArraySegment and changing the amqp message body type to Data for the interoperate with old .Net client library This resolves #138
Actual Behavior
MemoryStream
(with simplefoo bar
text) is converted tobyte[]
viaToArray()
and sent via ServiceBus@base64Binar3http://schemas.microsoft.com/2003/10/Serialization/? ?foo bar?
Expected Behavior
Explanation
We use ServiceBus for interaction between applications written on .NET and Java, where message content is XML text, written as "pure" bytes in to
Stream
ofBrokeredMessage
. We are planning to introduce new services written in NETCore, which should talk with existing services.There is no problem to call
memoryStream.ToArray()
to sendbyte[]
(in new services), but it's unacceptable that this data is being "packed" to some kind of serialization-envelope, because this require additional de-serialization step on receiving.I wrote sample app with both
WindowsAzure.ServiceBus
andMicrosoft.Azure.ServiceBus
, demonstrating the problem, here is output:How can I send "pure" content in
Message
? I found #98 with explanation about removingStream
body content, and agree about "need to be in memory" and "sends are taking a long time, when the latency is in fact caused by the reading of the stream", but is it really needed to use serialization-envelope, whilebyte[]
is the only content/payload type?Versions
Microsoft.Azure.ServiceBus 0.0.2-preview
andMicrosoft.Azure.ServiceBus 0.0.3-preview
WindowsAzure.ServiceBus 4.0.0
The text was updated successfully, but these errors were encountered: