I am working with subscription queries en Axon Server.
Suppose I have:
- A query command “QUERY”
- A query handler
- An eventListener emitting responses to “QUERY”
- Two update events (e1 and e2) resulting in two emitted updates u1 and u2 of type Update (Event event1.getUpdate().equals(u1))
- Axons QueryGateway (standard configuration) “queryGateway”
On the client side, I have:
`
SubscriptionQueryResult subscription1 = queryGateway.subscriptionQuery(new QUERY(), String.class, Update.class); //1
performActionCausingEventUpdate(e1); //2
subscription1.updates().blockFirst(Duration.of(15, SECONDS)); // expect u1 //3
SubscriptionQueryResult subscription2 = queryGateway.subscriptionQuery(new QUERY(), String.class, Update.class); //4
performActionCausingEventUpdate(e2); //5
subscription2.updates().blockFirst(Duration.of(15, SECONDS)); // expect u2 //6
`
On the server side, I have the following QueryHandler and listener:
`
@QueryHandler
public String handle(QUERY query) {
return “initial result”;
}
@EventHandler
public void on(Event event) {
queryUpdateEmitter.emit(QUERY.class, q->true, event.getUpdate());
}
`
Now, most of the time this works perfectly as espected.
But sometimes, the Flux stream from subscription 2 includes u1 followed by u2, where I expected this to be only u2, as I have waited for u1 to occur before starting to listen with subscription nr 2.
Why is this?