core-java
core-java copied to clipboard
Event from reaction is routed before the inititial event is dispatched to target
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.
@armiol, do you think this is a bug?
@dmitrykuzmin can you please check if this is still reproducible?
@dmitrykuzmin maybe we need an integration test on this matter.
The issue can no longer be reproduced.
A test for the described scenario was added in #1128.
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.