Closed arvigeus closed 6 years ago
Hi @arvigeus, RawRabbit uses Newtonsoft's JSON serializer out of the box. This serializser can not handle non-default constructors out of the box. There are a few ways to work around this, including adding constructor with attribute [JsonConstructor]
or a specific Converter
that understands how to create an instance of the message. Perhaps these links might be helpful:
This is kinda bummer because nothing communicates where is the problem. Should I close the issue now? Is there nothing that can be done about it to prevent confusion?
If you think about it, it makes sense that a serialization framework that takes a string and creates an instance of a type can't construct the type if the constructor requires argument and it doesn't know how to provide them. I'm closing this issue, as it is related to newtonsoft rather than RawRabbit. If you want, you can look at the other serialization options (RawRabbit currently supports Protobuf, ZeroFormat and MessagePack) and see if they fit your needs better.
Cheers!
RawRabbit 2.0-rc4 This is very peculiar: If a class has more than one constructor, sending it as a message does not work, unless one of the constructors is default one. I am using RawRabbit.Enrichers.Attributes Example (see comments):
Full code for reference