I have three different services(A,B & C) running and all are connected to axonserver 4.3.3. Apart from them i an api service which contains all events so that it can be shared among all services. when an event is fired(lets say by service A) it is being listened by other services(B & C) and they react accordingly.
Now i want to share queries as well so that when a service(Lets say A) wants some information which belong to another services(lets say B), it can directly fire corresponding query which will listened by service B and will return the info.
- Is it allowed in axon(i.e., sharing query among services, like we do for events)?
- If allowed, does it follow axon best practices ?
- If not allowed/doesn't follow best practices, what is alternate solution ?
UPDATE
I simply added queries to the common-api service and fired it from Service A as follows:
- when i used
queryGateway.query( findCourierByIdQuery, responseType): i got queryhandler not found exception - when i used
queryGateway.subscriptionQuery( findCourierByIdQuery, initialResponseType, updateResponseType): i got nothing - when i used
queryGateway.scatterGather( findCourierByIdQuery, responseType, timeout, timeUnit): i got an empty stream
when i fired the findCourierByIdQuery from service B itself, the queryhandler was invoked and i got the proper response.
My observation is that, the query-handler only gets called if the query has been fired from the same component(service B in this case), it is not getting called if i fire the query from some other component(service A).
Note that all services are running independently on different hosts and ports, but connected to the same axonserver and the queryhandler is written in service B.
so basically the implementation is something like this:
- findCourierByIdQuery is defined in common api service.
- Service A and B has the dependency of common api service.
- service A does the query for findCourierByIdQuery.
- Service B has the findCourierByIdQuery query handler implementation.