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

Inconsistent reference documentation on republication of incomplete event publications #818

Closed
breun opened this issue Sep 12, 2024 · 4 comments
Assignees
Labels
in: reference documentation Our own reference documentation type: bug Something isn't working
Milestone

Comments

@breun
Copy link

breun commented Sep 12, 2024

https://docs.spring.io/spring-modulith/reference/events.html#publication-registry says: "By default, all incomplete event publications are resubmitted at application startup."

However, https://docs.spring.io/spring-modulith/reference/appendix.html#configuration-properties says that the default value for spring.modulith.republish-outstanding-events-on-restart is false. This is indeed also specified in the Spring configuration metadata. This seems to contradict the first statement.

Looking at the implementation of org.springframework.modulith.events.support.PersistentApplicationEventMulticaster#afterSingletonsInstantiated it looks like incomplete publications are only resubmitted when spring.modulith.republish-outstanding-events-on-restart is explicitly set to true.

@odrotbohm odrotbohm self-assigned this Sep 13, 2024
@odrotbohm odrotbohm added type: bug Something isn't working in: reference documentation Our own reference documentation labels Sep 13, 2024
@odrotbohm odrotbohm added this to the 1.3 M3 milestone Sep 13, 2024
@odrotbohm
Copy link
Member

Your observation is correct. The former, erroneous section stems from the time when the default was the opposite before we flipped the flag for improved production-readiness.

@odrotbohm odrotbohm changed the title Confusion about default republishing of outstanding events on restart Inconsistent reference documentation on republication of incomplete event publications Sep 13, 2024
@breun
Copy link
Author

breun commented Sep 13, 2024

I see you added this in the documentation: "Usually not recommended in multi-instance deployments as other instances might still be processing events." What is the recommended way to deal with this for multi-instance deployments?

@odrotbohm
Copy link
Member

Some application component using @Scheduled and IncompleteEventPublications as currently you cannot differentiate between publications currently in process versus ones that have failed. Thus, you'd usually resubmit only publications older than a certain time frame, depending on how long you expect the listeners to take. Furthermore, you'd have to guard against multiple instances processing the outstanding evens by using something like SchedLock.

We are tracking improvements to the publication lifecycle in GH-796 and a better out-of-the-box locking experience but without any concrete plans yet.

@breun
Copy link
Author

breun commented Sep 13, 2024

This sounds like a pretty risky pitfall for users that may think multi-instance setups will currently Just Work™ (like myself until today).

Would it be an idea to document the things that multi-instance applications will currently need to take care of themselves (maybe with some recommendations/examples)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: reference documentation Our own reference documentation type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants