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

Exclusive incomplete events republication #871

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

joshlong
Copy link
Member

I've been thinking about republishing incomplete events on restart. there are two things i think we could improve

a) the incomplete events should run after the spring boot health check is green, otherwise a sufficiently large number of incomplete events could cause the program to fail to start in time on Kubernetes or Cloud Foundry, and then we'd get even more missed events, and the cascading dogpile would be horrendous.

b) we could provide a cluster-wide locking and exclusive implementation, so that when, say, five instances of the same service restart, only one actually processes the incomplete events. Spring Cloud introduced a distributed locking mechanism 8 years ago, and it moved into Spring Integration sometime before the pandemic. So, ive introduced support for that in this branch. This of course starts to muddy the code, so I extracted out the default behavior (resubmit all, assuming the property is set) and this exclusive locking behavior (resubmit all, assuming property is set and the lock name is specified) into two separate classes, with appropriate auto configuration so that one gets chosen if the other doesn't.

This PR establishes a new interface for things that will reprocess outstanding events on restart. I've moved them to run at the same time as ApplicationRunner does, a bit later in the lifecycle. There are now two implementations. The default behavior is as it has always been: to run all outstanding incomplete events. There's also a new implementation guarded by a new property (establishing a lock name) and a check for the correct classes on the classpath that uses Spring Integration's distributed lock support. Obviously, Spring Integration doesn't offer locks for every persistence tier that Spring Modulith supports, so perhaps we could expand Spring Integration's support or also offer schedlock support as an alternative, additional autoconfiguration.

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

Successfully merging this pull request may close these issues.

1 participant