I’m trying to return the content of the PostgreSQL JSONB column from a query. In the query response object, I have a String field marked with Jackson’s @JsonRawValue annotation. In a query handler, as far as I could track, the field is correctly serialized as unescaped JSON string before it is sent to the Axon server. Unfortunately, I’m getting a null from a query gateway. If I remove the @JsonRawValue annotation, the gateway returns the field, but in escaped form.
Before diving deeper, I just want to check whether this is a known limitation or not. If there is some sample app doing the same thing, I would appreciate it if somebody points me to it.
I’m using Axon Framework 4.6.2 with Spring Boot 2.7.5 and Axon Server 4.6.6.
After some further debugging and googling, it looks like it is a Jackson thing. Annotation @JsonRawValue is only for serialization, while for deserialization, I need a custom deserializer. Something like the one described here: Deserializing JSON property as String with Jackson.
Happy to hear you’ve found a way to make this work, @dmurat!
Also, it’s very helpful that you’ve provided the answer in this thread.
It’ll most definitely help others with the same predicament.
Just a small addition: I already couldn’t conceive how Axon Framework or Axon Server was holding you back here.
As long as the response from the Query Handler is something Axon’s Serializer can de-/serialize, you should be good.
So, if you’d push the raw JSON into a String (for example), things should work.