Query responses are serialized with the Default Serializer instead of the Message Serializer
See original GitHub issueBasic information
- Axon Framework version: 4.5.8
- JDK version: 11
- Complete executable reproducer if available (e.g. GitHub Repo):
Steps to reproduce
This scenario describes what I was doing at that time, but it can be reproduced in many other ways.
My Event Serializer and Message Serializer (as defined in the doc) are configured to use Jackson. I do not configure the default Serializer, meaning it will use the XStream implementation by default.
I implemented a PageResponseType
as explained in this issue comment for my query responses.
When sending a query expecting a PageResponseType
response, I ended up with an XStream security exception.
Expected behaviour
I expected XStream not to be involved in the serialization of the response, but rather Jackson because I configured a Message Serializer for Axon Framework.
Actual behaviour
XStream was used as a serializer implementation, meaning Axon’s default Serializer was used, resulting in an error in my case (because I did not explicitly configure XStream to allow my response class, but this is another matter).
To summarize, reading the docs made me believe that the Message Serializer would be used for Query messages AND Query responses, but it seems to be used only for the Query message, leaving the Query response to the default serializer. Is this intentional? If yes, then this issue should not be a bug report but I would really like to see this explained in the documentation.
As a side note, this behavior may be the same for Command responses, but I did not test it.
Cheers!
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:7 (7 by maintainers)
Everything makes sense in my head now! Thank you again for taking the time to give so much details!
Ah I think I get it! Thanks for taking the time to explain.
Let me rephrase so I can be sure I get it right.
I indeed have a
PageResponseType
describing the type of response I expect, which is a customPage
implementation.So I have this scenario in mind:
FindAllSomethingQuery
query through the query gateway specifying that aPageResponseType(Something.class)
is expected:FindAllSomethingQuery
instancePage<Something>
as the response dataPage<Something>
Page<Something>
instance@smcvb Is this scenario correct?