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

GH-8680: Check DB for table on start #8690

Merged
merged 5 commits into from
Jul 28, 2023

Conversation

artembilan
Copy link
Member

Fixes #8680

If database is not initialized properly before application start, we may lose messages at runtime when we fail to insert data into DB

  • Implement SmartLifecycle on JdbcMessageStore, JdbcChannelMessageStore, JdbcMetadataStore, and DefaultLockRepository to perform SELECT COUNT query in start() to fail fast if no required table is present.
  • Refactor AbstractJdbcChannelMessageStoreTests into JUnit 5 and use MySqlContainerTest for more coverage
  • Fix newly failed tests which had DB not initialized before
  • Exclude commons-logging from commons-dbcp2 dependency to avoid classpath conflict
  • Document the new feature

Fixes spring-projects#8680

If database is not initialized properly before application start, we may lose messages
at runtime when we fail to insert data into DB

* Implement `SmartLifecycle` on `JdbcMessageStore`, `JdbcChannelMessageStore`,
`JdbcMetadataStore`, and `DefaultLockRepository` to perform `SELECT COUNT` query in `start()`
to fail fast if no required table is present.
* Refactor `AbstractJdbcChannelMessageStoreTests` into JUnit 5 and use `MySqlContainerTest`
for more coverage
* Fix newly failed tests which had DB not initialized before
* Exclude `commons-logging` from `commons-dbcp2` dependency to avoid
classpath conflict
* Document the new feature
artembilan and others added 2 commits July 28, 2023 12:36
Co-authored-by: Gary Russell <grussell@vmware.com>
@artembilan artembilan requested a review from garyrussell July 28, 2023 17:06
@artembilan
Copy link
Member Author

I guess when we are settled with this, we can expose such a property in Spring Boot to disable it globally, for example, for those applications which are working against stable environment with properly managed DB.
And it even can be false by default according to the DataSourceInitializer statement.

Co-authored-by: Gary Russell <grussell@vmware.com>
@garyrussell garyrussell merged commit 7dcc0bb into spring-projects:main Jul 28, 2023
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.

Jdbc Backed QueueChannel fail fast if DB is not initialized properly
2 participants