Flux from QueryHandler?

Hello team!

Is it possible to return a Flux from a QueryHandler?

I’d like to stream thousands of records to the client. Axon Server complains when you surpass its maximum message size, and while this can be adjusted, is probably not an ideal solution. The QueryUpdateEmitter seems like it almost does the job, but in this case it is a simple response to a query rather than an update.


Hi Joel,

unfortunately, the APIs currently don’t allow that. We’ve been discussing this in the product team. The idea is to allow a stream of responses to be sent, instead of just a single response with multiple entries.

But that’s future talk… you’re limited to a single response message, for now.

It appears to be technically possible using a query subscription, where the emitting filter is set to { it == query }. The hacks required are to 1) trigger the query handling using query.initialResult().subscribe() and 2) return null from the query handler, which sidesteps Axon’s requirement that every query handler must return something. I wont be putting this in production but it looks like you’re mostly there already. :slight_smile:

I’ve been punished by that latter requirement on a number of occasions. I’d love for the ability to write query handlers w/o return values to facilitate general message passing. Call it a query bus or otherwise, it’d be useful.