-
Notifications
You must be signed in to change notification settings - Fork 265
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
Implementing a Process Manager #72
Comments
Hi.
I’m on vacation, so I don’t get to try anything out, but I don’t get why the session isn’t cleared. Could you please elaborate?
Could it work to create a new session for the second commit?
Mvh
Gaute Magnussen
… On 26 Mar 2018, at 19:41, GuiguiMtl ***@***.***> wrote:
On a previous Issue I asked of the difference between Process Manager and Session and ended up creating a process manager.
One of the issue I am facing is that as a result several Aggregate are being tracked in the Session. When I commit for the first time the tracked aggregates are not cleared therefore still tracked. That's probably because
So during the second commit, it tries to save the aggregate previously save again but this create a Concurrency Issue because the version of the aggregate descriptor is not updated.
One solution I have found it to update the commit with this
await Task.WhenAll(_trackedAggregates.Values.Where(aggregate => aggregate.Aggregate.GetUncommittedChanges().Any()).Select(x => _repository.Save(x.Aggregate, x.Version, cancellationToken)));
In order to only save Aggregates that does not have any other changes to save.
The other option would be to not wait for the save of aggregate to be finished to actually clear the tracked aggregates of the session but I can't figure a way to make that work.
Does that make sense or am I going to break something I do not realize yet ?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Thanks for your answer. The session is not cleared because after committing the first aggregate, the event is broadcasted to the system. It is handle by the event handler which creates and save the process manager. At this point the session keeps track of the aggregates that was saved previously and the process manager. That's because even if it is asynchronous everything is done in this given order : Creating a new session in the handler would probably fix the issue but I feel like it would break the idea of Session you were trying to bring with it, no ? |
Sorry the late reply. I don't think you should use the same session. Hopefully you have fixed this by now. |
On a previous Issue I asked of the difference between Process Manager and Session and ended up creating a process manager.
One of the issue I am facing is that as a result several Aggregate are being tracked in the Session. When I commit for the first time the tracked aggregates are not cleared therefore still tracked. That's probably because
So during the second commit, it tries to save the aggregate previously save again but this create a Concurrency Issue because the version of the aggregate descriptor is not updated.
One solution I have found it to update the commit with this
await Task.WhenAll(_trackedAggregates.Values.Where(aggregate => aggregate.Aggregate.GetUncommittedChanges().Any()).Select(x => _repository.Save(x.Aggregate, x.Version, cancellationToken)));
In order to only save Aggregates that does not have any other changes to save.
The other option would be to not wait for the save of aggregate to be finished to actually clear the tracked aggregates of the session but I can't figure a way to make that work.
Does that make sense or am I going to break something I do not realize yet ?
The text was updated successfully, but these errors were encountered: