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

Event sourced projection event is not correctly handled in complex flows #104

Closed
jlabedo opened this issue Apr 21, 2023 · 5 comments
Closed

Comments

@jlabedo
Copy link
Contributor

jlabedo commented Apr 21, 2023

Ecotone version(s) affected: 1.79.0

Description
In the context of 2 event sourced aggregates, both aggregates having projections on their stream,
Then, with a synchronous flow being command (Agg1_id1)=>Event(Agg2_id1)=>Command(Agg1_id1), the events from Agg2 handled in its projection are not handled in the context of a projection handler, but as a "common" event handler.
This breaks the projection, as the projection state is not updated and persisted, and the projection is not initialized.
There is no bug in the case of different ids on Agg1: (Agg1_id1)=>Event(Agg2_id1)=>Command(Agg1_id2) works as expected

How to reproduce
See modified EventSourcing example in:
https://github.com/jlabedo/ecotone-dev/tree/failing-es-projection/quickstart-examples/EventSourcing
The example show that SagaProjection is not initialized when we create a product with Id=3

Context
The case is pretty awkward, and we found it in a badly designed use case. We fixed it by redesigning correctly our aggregates

@dgafka
Copy link
Member

dgafka commented Apr 22, 2023

Hey,
Nice edge case :)

Can you provide PR with test case (you may copy paste your example into package/PdoEventSourcing/tests/Fixture/*) using Ecotone Lite with support for testing Event Sourced Application?

@jlabedo
Copy link
Contributor Author

jlabedo commented Jun 1, 2023

Hello @unixslayer, I got another use case that can be even more problematic : if the event sourced aggregate records 2 events and both events are listened by the same projection, the projection will fail in the same manner. Hope that helps, I may try to add a test for that

@unixslayer
Copy link
Member

@jlabedo currently both with @dgafka we are working on an issue around metadata propagation in #134. This may be related to or have an impact on your case which I'll get back to as soon as we finish with that one.

@dgafka
Copy link
Member

dgafka commented Jun 4, 2023

This is now fixed with 1.87.0.

@dgafka dgafka closed this as completed Jun 4, 2023
@unixslayer
Copy link
Member

@jlabedo one thing was changed in your test case during debugging. What I did was change the behavior of Saga so that it won't send a command before returning SagaStarted event. There is an additional EventHandler for SagaStarted event which will send that command. Currently, both approaches would work, but as you may see in SynchronousEventDrivenSagaTest::test_product_is_added_by_synchronous_event_driven_saga events are recorded in more predictable order where a product gets added to the basket after Saga is started. Before, the product was added before Saga gets started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants