I have the below query handler which return a map
@QueryHandler
fun on(query: GetOrderStatusExtended): Mono<Map<String, Any>> = click2payClientApi.getOrderStatusExtended(
query.userName,
query.password,
query.orderId
)
I have the below api
@GetMapping
fun getOrderStatusExtended(
@RequestParam userName: String,
@RequestParam password: String,
@RequestParam orderId: String
): Mono<Map<*, *>>? = queryGateway.query(GetOrderStatusExtended(userName, password, orderId), Map::class.java)
when i test it, i get this error
org.axonframework.queryhandling.NoHandlerForQueryException: No handler found for [com.test.GetOrderStatusExtended] with response type [InstanceResponseType{interface java.util.Map}]
The solution is rather easy in this case.
The return type of Map
is not something Axon Framework can deal with.
All the reflection logic in place will only validate the first generic but does not deal with a second one.
As such, the current implementation of the framework’s ResponeTypes
does not allow you to use a Map<?,?>
.
There is actually an outstanding issue to support a MapResponseType
within the framework, which you can find here.
To resolve this, you need to adjust the return type to either a concrete object or a Collection
.
So, easiest would be to map the result of your click2payClientApi
into a specific Query Response object.
You can then use that as the expected responseType
wheb performing your query in the get-mapping.
Lastly, note that Axon Framework does require you to use the Reactor Extension to use Mono
/Flux
as response types. I felt obliged to point that out since based on your code snippets it is not clear whether you are using that.
At any note, I hope this helps, @ounirayen!
1 Like