-
Notifications
You must be signed in to change notification settings - Fork 749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EasyNetQ Json.NET JObject serialization - surprising behavior #460
Comments
Don't forget that EasyNetQ serializes .NET types as JSON to send them over var properties = new MessageProperties(); On Wed, Jun 24, 2015 at 9:13 PM, Todd Ogin notifications@github.com wrote:
|
The EasyNetQ use ilmerge to include the Newtonsoft.Json assembly now, so it doesn't have to have an external dependency on Newtonsoft. So internally, it uses it has it's own copy of When you pass your When you create your custom serializer you are effectively saying don't use the "version" of Newtonsoft in the EasyNetQ assembly. So now when you pass your |
@ojintoad why are you trying to publish instances of JObject, instead of "normal" objects? That seems strange, how would you consume them? |
To answer @mikehadlow and @zidad the example is contrived. The actual use case has the JObject as a property of a well defined type. Yes, we could serialize the jobject first but that involves handling this message as a special case. The serializer solution alleviates that. The answer @codenaked provides makes sense. I certainly would prefer not having to add the serializer, but it sounds like EasyNetQ has made a decision about Json.NET that makes this required. I wasn't necessarily looking for a code change. The explanation provides sufficient justification for me to leave my workaround in and document it in our own code base so developers are informed of its purpose. If there are other suggestions I'm happy to hear them, but I'm also happy with the response here and feel this issue can be closed. |
I suppose one of the reasons why one would want EasyNetQ to serialize JObjects as one would expect is in the use case where one wants to mix structured and unstructured data on the message that gets passed to the bus. In @ojintoad's original example, imagine that instead of
|
I'm seeing somewhat weird behavior when trying to send Json.Net JObjects through EasyNetQ's Default Serializer.
Here's a contrived example:
The object that gets published is:
Which leaves me sort of 😞
So I saw this issue: #237
Where it was suggested to a user to reimplement the json serializer. So I did that:
And out comes:
Which leaves me 😀 .
The thing is that Serializer is basically the EasyNetQ serializer without EasyNetQ dependencies present so it will compile properly.
I'm happy to have a solution, but it just seems like weird behavior that it's behaving this way with what seems like identical code.
For reference:
Using Visual Studio 2013, Rabbit MQ 3.4.1 locally installed on Windows
Code snippets tested with: EasyNetQ 0.50.1.392, Json.NET 7.0.1
The text was updated successfully, but these errors were encountered: