Querying from within an @EventHandler fails during replay

Hi all,

TL;DR: when trying to send a query via the QueryGateway for within a @EventHandler during replay, you get can … because of the start-up order. Events get replayed before the @QueryHandlers are subscribed resulting in no query handlers found. Is there a way to resolve this?

Hi Bob,

This configuration order is indeed the reason why a Query Handler is not subscribed to the QueryBus yet whilst you’re already issuing the replay.
We have plans to be a little stricter on the configuration ordering of all the infrastructure components; I can however not give you a time frame on when this will be resolved.

To solve the problem you have though, I’d like to suggest that you leverage the Replay API as has been introduced into Axon 3.3.
Although this is an assumption from my part, I assume that you’re starting a replay by throwing away the Tracking Token.
This will issue a replay, but in a manor that the framework cannot deduce whether you’re performing a replay or simply started the application for the first time.
Taking control over this provides several benefits, like allowing the use of the @ResetHandler annotated function or the @AllowReplay annotation to ignore some event handling functions.

Additionally, opening up that API for yourself gives you the control to start the replay once your application is correctly started up.

If you feel this suggestion does not correctly resolve the problem you’re having, as the ordering is of the utmost importance on start up, I’d like to ask you to add an issue to GitHub.
This will serve as a helpful means for the development team to discuss the problem/suggestion at hand.

Hope this helps you out Bob!


Hi Steven,

Thank you for the elaborate and quick response.

Unfortunately we aren’t using the TrackingToken at the moment but are using a custom implementation of the Subscribing event processor. We will investigate if switching to a Tracking Event Processor is a valid option for us as I gather from your response that it’s not possible to alter the order.

Kind regards,