In my spring-boot project i have 2 separate services for command and query. Both services are connected to axon and sharing the same database.
My ui is designed in such a way that, when user submits the form to create some data, the ajax makes calls to command-service in order to save the data in database and upon a succesful save it immediately calls to query-service in order to fetch the saved data.
The probelm here is the query-service is not always able to get the newly created data as it is querying the database before the command-service finishes it’s execution(creating data in databse).
I think the solution here is to make org.axonframework.commandhandling.gateway.CommandGateway.sendAndWait(Object) wait untill the command-handling complets, so that the ajax will call query-serivce only after the command-service completes.
Can someone please suggest whether it is achievable or not ? if yes then how to achieve this.