core-java icon indicating copy to clipboard operation
core-java copied to clipboard

Event from reaction is routed before the inititial event is dispatched to target

Open mdrachuk opened this issue 6 years ago • 5 comments

This leads to an issue, when there is an event (UserSignedIn) which creates another event as a reaction (UserConsentRequested) and they both are dispatched to a single entity (SessionProjection) with the first event (UserSignedIn) actually creating it, and the second event requiring a repository (SessionRepository) query to be routed to the correct target.

As of now, after routing an event to a projection, a DispatchEventToSubscriber command is posted to the System Bounded Context, after which the next event from queue gets dispatched.

This means that upon dispatching two events from the DispatchQueue, when it comes to the second event, the first one is not dispatched, but scheduled to be dispatched in the System Bounded Context.

mdrachuk avatar Dec 21 '18 18:12 mdrachuk

@armiol, do you think this is a bug?

alexander-yevsyukov avatar Feb 08 '19 20:02 alexander-yevsyukov

@dmitrykuzmin can you please check if this is still reproducible?

armiol avatar Jul 25 '19 09:07 armiol

@dmitrykuzmin maybe we need an integration test on this matter.

armiol avatar Jul 25 '19 09:07 armiol

The issue can no longer be reproduced.

A test for the described scenario was added in #1128.

dmitrykuzmin avatar Jul 31 '19 09:07 dmitrykuzmin

This behavior is now reproducible again. However, it does not look an outstanding issue, as the read-side by contract is eventually consistent. While in this scenario the code relies not only upon the ordering of the events dispatched to the projection (which is guaranteed by the framework) but onto the projection state changes that presumably should have taken place.

armiol avatar Nov 19 '19 12:11 armiol