Skip to content

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

Merged
garyrussell merged 5 commits into
spring-projects:mainfrom
artembilan:GH-8680
Jul 28, 2023
Merged

GH-8680: Check DB for table on start#8690
garyrussell merged 5 commits into
spring-projects:mainfrom
artembilan:GH-8680

Conversation

@artembilan

Copy link
Copy Markdown
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
Comment thread src/reference/asciidoc/jdbc.adoc Outdated
Comment thread src/reference/asciidoc/whats-new.adoc Outdated
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
Copy Markdown
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