Marking event as completed may fail when used with ChainedTransactionManager
#886
Labels
in: event publication registry
Event publication registry
meta: waiting for feedback
Waiting for feedback of the original reporter
I run into a following issue:
Project has a little unusual setup:
@Primary
org.springframework.data.transaction.ChainedTransactionManager
configured for two transactions managers mentioned aboveThe code looks more or less like this:
When
barService.bar()
is called, in logs I can see that handling of the event in the listener may happen afterFooService#foo
method finishes and beforeBarService#bar
finishes, but the event publication is inserted afterBarService#bar
method finishes execution. So there is a chance, that marking event as completed happens before the event publication is inserted.Sample that reproduces this issue: https://github.com/maciej-scratches/modulith-chainedtransaction-manager-issue/blob/main/src/test/java/org/example/FooServiceTest.java#L43
Due to asynchronous nature, it's not easy to reproduce. When test runs 100 times, on my machine usually fails once or twice.
Considering that
ChainedTransactionManager
is deprecated perhaps this issue is irrelevant, but I am raising it as it maybe affects also other arrangements I am not aware of - if this is not the case - feel free to close it.The text was updated successfully, but these errors were encountered: