spring-projects / spring-modulith

Modular applications with Spring Boot
https://spring.io/projects/spring-modulith
Apache License 2.0
774 stars 124 forks source link

Allow differentiating between failed event publications and ones that are currently processed #663

Open cmetzlerhg opened 2 months ago

cmetzlerhg commented 2 months ago

Hi,

we ran into another issue with multiple nodes (using jpa event publication), where one node tries to handle the event via the local application event publishing mechanism, whilst the other node tries to replay incompleted event (because it has not been marked as completed yet). For now we mitigated the issue, by only replying events older than x seconds to avoid the same event handler to be triggered twice on different nodes. I wonder, if it would be useful that any event handler either keeps a lock in the database while processing an event or uses a state field (wether the event is currently being processed).

What would be your recommendation?

odrotbohm commented 2 months ago

This is indeed a current limitation, also evident from the fact that IncompleteEventPublications exposing a ….resubmitIncompletePublicationsOlderThan(Duration). We have plans to overhaul the event processing infrastructure to explicitly mark publications as failed that couldn't be processed.

cmetzlerhg commented 2 months ago

Thanks for your quick reply, I think for now, we are fine with using an offset. Whenever there is a solution we're happy to adopt it.