Why subscription query requires initial response?

Hello everybody!

First of all, thanks to everyone involved in development of the Axon Framework, which immensely helps with developing event sourcing-based applications in Java! I’m working on an issue that requires me to receive incremental updates on state of certain entities - a perfect use case for subscription queries. The consumer of these updates is not interested in any previous state of those entities and only wants to receive updates from the point of subscription.

As far as I’m concerned, there’s no way in Axon to create a subscription query without providing initial response type. But even if I do it, the QueryUpdateEmitter won’t emit any update messages for my subscription unless I implement a no-op @QueryHandler for this subscription query, which is (as well as initial result type parameter) obviously redundant in this case and makes the code harder to understand.

That makes me wonder what was the reason for the Axon team to make initial result of subscription queries mandatory? Or is it just a low priority task for you to do in the future? Or maybe I just didn’t figure out how to make such queries without creating an unused @QueryHandler?

Thanks in advance :slight_smile:

Hi Johnny,

Thank you for your kind words regarding the development of Axon Framework. Much appreciated!
A short answer for the necessity of having a @QueryHandler is so that the queries get subscribed on the QueryBus. Otherwise, there wouldn’t be a place for the original query to go to. And even though it is not necessary in your case to have the initial result, there are many cases where it is useful/needed. I think that the initial result was added in order to make sure that it contains all that is required in the query up to that point. But I am not 100% sure, sorry. :slight_smile: