Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow prevention of @QueryHandlers when the Event Handling Component backing the query handler is Replaying #2949

Open
smcvb opened this issue Dec 21, 2023 · 2 comments
Labels
Priority 3: Could Low priority. Issues that are nice to have but have a straightforward workaround. Type: Enhancement Use to signal an issue enhances an already existing feature of the project.

Comments

@smcvb
Copy link
Member

smcvb commented Dec 21, 2023

Enhancement Description

The scenarios are plenty wherein a Message Handling Component (MHC) combines @EventHandler and @QueryHandler annotated methods.
The event handlers update the projection and the query handlers answers queries through the projected data.

Whenever such a MHC, or Projector, is replaying, the query handlers would likely serve stale data.
Hence, if we provide functionality that disables the query handlers from being invoked if the MHC/Projector is replaying, we would have an automatic protective measure.

Current Behaviour

Query handlers are invoked, regardless of whether the component they're in is actively replaying.

Wanted Behaviour

Users can choose whether a query handler should react to an active replay so that their behavior can be disabled for the duration of the replay.

Possible Workarounds

It is doable to implement logic yourself into the MHC that knows the replay is triggered.
This can be a plain setting for the application before start-up, through an endpoint that triggers the replay, or perhaps through a Spring profile, that lets the MHC behave differently for query handlers.

Knowing when the replay is done is tougher, requiring validation of the Streaming Event Processors progress, and once the tokens are out of their replay state, to switch the previously mentioned toggle.

@smcvb smcvb added Type: Enhancement Use to signal an issue enhances an already existing feature of the project. Priority 3: Could Low priority. Issues that are nice to have but have a straightforward workaround. labels Dec 21, 2023
@ZakMcKrack3n
Copy link

Also , in case of command side components using @EventHandler to build their lookups, it would also be nice to have the prevention of @CommandHandlers in addition to @QueryHandlers.

@smcvb
Copy link
Member Author

smcvb commented Mar 15, 2024

Also , in case of command side components using @EventHandler to build their lookups, it would also be nice to have the prevention of @CommandHandlers in addition to @QueryHandlers.

Fair point, @ZakMcKrack3n!
Although the chance is typically slimmer that this occurs as most users utilize an Event Sourced Aggregate (which already protects you from this), it still makes sense for "simple" Command Handling Components that, on the side, have some Event Handlers to update their (local) state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority 3: Could Low priority. Issues that are nice to have but have a straightforward workaround. Type: Enhancement Use to signal an issue enhances an already existing feature of the project.
Projects
None yet
Development

No branches or pull requests

2 participants