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

How to solve the issue of business validation inaccuracies caused by projection delays? #3017

Open
yyc6698 opened this issue Apr 29, 2024 · 7 comments
Labels
Type: Enhancement Use to signal an issue enhances an already existing feature of the project.

Comments

@yyc6698
Copy link

yyc6698 commented Apr 29, 2024

Enhancement Description

Currently, when attempting to create a draft for an application, there is a need to verify if the draft already exists. However, due to delays in updating the read models or projections, this verification can sometimes be based on stale data, leading to incorrect assessments or duplicate entries.

Current Behaviour

Axon Framework allows for eventual consistency in the projections of events. This approach, while efficient in many scenarios, can cause delays between the command handling that generates events and the update of the read models. In my case, when I create a draft and simultaneously check if it already exists, I face issues due to this delay.

Wanted Behaviour

I would like Axon Framework to provide a more robust solution for real-time verification against the read model, even when working within an eventually consistent system. This might include tools or patterns that help ensure that critical verifications, like checking for the existence of a draft, are accurate despite the inherent delays in the system.

@yyc6698 yyc6698 added the Type: Enhancement Use to signal an issue enhances an already existing feature of the project. label Apr 29, 2024
@yyc6698 yyc6698 changed the title I encountered an issue while using Axon. I needed to create a draft for a certain application but also had to verify if the draft already existed. When I queried the repository, there was a delay, leading to a misjudgment in my verification. Do you have any suggested solutions for this kind of problem? How to solve the issue of business validation inaccuracies caused by projection delays? Apr 29, 2024
@gklijs
Copy link
Member

gklijs commented Apr 29, 2024

Why isn't it enough to check if the aggregate already exists?

@yyc6698
Copy link
Author

yyc6698 commented Apr 29, 2024

Why isn't it enough to check if the aggregate already exists?

Aggregates are checked in Axon using the aggregate root ID. For instance, in current business processes such as approval documents, the aggregate root ID might be the approval document ID. However, to verify whether a person has initiated a specific approval, it is necessary to query using a different ID.

@gklijs
Copy link
Member

gklijs commented Apr 29, 2024

Is initiating the approval not done via a command?

@yyc6698
Copy link
Author

yyc6698 commented Apr 30, 2024

Is initiating the approval not done via a command?

This is accomplished through commands. In our business model, an individual in a specific unit can only initiate one approval document. This type of verification is currently done after receiving a command, by querying the repository. Once verified, an event to create the approval document is issued. However, due to delays in the repository, there is a possibility that the verification could be invalidated.

@gklijs
Copy link
Member

gklijs commented Apr 30, 2024

Ok, this is getting too complex and out of scope. Typically you should be able to model the constraints in the aggregate. I don't think that's impossible in this case, but certainly could be challenging.

The read model could always be behind. What can be done is het the events/state of another aggregate. Although you still might run into problems as the other aggregate might be changed.

@michelkaeser
Copy link

Similar to what is suggested here https://www.axoniq.io/blog/2020set-based-consistency-validation you can always introduce strongly consistent projections in the write model as well via subscribing event processors and use these during business validation. Maybe that helps.

@yyc6698
Copy link
Author

yyc6698 commented May 6, 2024

Similar to what is suggested here https://www.axoniq.io/blog/2020set-based-consistency-validation you can always introduce strongly consistent projections in the write model as well via subscribing event processors and use these during business validation. Maybe that helps.

We are currently utilizing this approach as well, but we have encountered an issue where transactions are not supported. In cases where exceptions occur during subscription tracking processing, events still get stored in the database, thereby failing to ensure transactional integrity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Use to signal an issue enhances an already existing feature of the project.
Projects
None yet
Development

No branches or pull requests

3 participants