I’m building a component that is interested in the
MetaData of all messages passed around. I started with passing
MetaData with commands, adjusted the aggregates to pump it into the resulting events and have some idea how to store them in the projections. On this point I’m stuck at the query side.
I can pass
MetaData along with the query, but I can’t get it from my projection to the
QueryResponseMessage. The only two values I see there are:
I there any way, I can pass it out of the projection without changing the return type?
I found that there is an interceptor chain invoked before the handler, but not after the query handler invocation (see
It is not stated in the docs, but
GenericQueryResponseMessage#asNullableResponseMessage seems to be at least prepared to the fact, that the handler invocation is returning a message instead of the payload. In the same time, I could not yet found a way to register a handler returning a
QueryResponseMessage<T> to be dispatched by the query for
Is it intended to be used it like this?
Glad about any ideas.
After debugging a-little I found how the handler is selected and implemented an own
ReturnType for let the
QueryResultMessage return type to match the query. By doing so, the query handler returning the
QueryResultMessagenow gets invokes. On the deserialization of the result message the following error appears:
2020-09-30 21:21:07.545 ERROR 118470 --- [nio-8081-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path  threw exception [Request processing failed; nested exception is java.util.concurrent.CompletionException: org.axonframework.queryhandling.QueryExecutionException: class org.axonframework.serialization.UnknownSerializedType cannot be cast to class org.axonframework.messaging.responsetypes.ResponseType (org.axonframework.serialization.UnknownSerializedType and org.axonframework.messaging.responsetypes.ResponseType are in unnamed module of loader 'app')] with root cause
This message is coming from Axon Server Connector, so it seams that Axon Server fails to work with my provided result type.
Is there any way to solve this on the “framework level” and not introduce own envelope for the result type which contains metadata?