Skip to content

Allow using a system property to set cron task of cleaning up expired JDBC sessions #621

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

Closed
wants to merge 5 commits into from

Conversation

ajthom90
Copy link

@ajthom90 ajthom90 commented Sep 8, 2016

Issue #616

Allow using a system property to set CRON expression for cleaning up expired JDBC sessions. It looks like the @Scheduled annotation wouldn't allow a placeholder to be resolved with a system property, so adding the task to the task registrar is now handled in the JdbcHttpSessionConfiguration. Also, there is now a property on @EnableJdbcHttpSession to set the CRON expression.

…r JDBC cleanup

Using a system property or a property on @EnableJdbcHttpSession to set
the CRON expression used to run the clean-up task
…r JDBC cleanup

Using a system property or a property on @EnableJdbcHttpSession to set
the CRON expression used to run the clean-up task
Fixing checkstyle error.  Added period to end of sentence.
Fixing another checkstyle violation...
@rwinch
Copy link
Member

rwinch commented Sep 12, 2016

Thanks for the PR! I'm interested in why you find this change necessary? Generally speaking I don't think this would really need to change.

@rwinch rwinch added the status: waiting-for-feedback We need additional information before we can continue label Sep 12, 2016
@ajthom90
Copy link
Author

Hi @rwinch, thanks for the feedback!! As I described in Issue #616, I'm running into issues in environments with multiple application servers connected to multiple databases. At the top of the minute, both servers are kicking off the JdbcOperationsSessionRepository#cleanUpExpiredSessions() method to clean up sessions on their databases. When the databases try to delete the data on the other servers through replication, it runs into errors because the data it is expecting to be there is actually not there. This change would allow a system property to be set on each server for the Cron expression, so, for example, one server could run the cleanUpExpiredSessions() method at the top of every minute, and the other server could easily be set to run cleanUpExpiredSessions() at the 30 second point of every minute. Sorry, I'm not the best at explaining things sometimes, so I hope this makes sense! Let me know if you have any other questions.

In my app, I've essentially set up the solution that @vpavic suggested in his comment on Issue #616 yesterday, but I was just adding a pull request in case others thought it may be useful!

@rwinch
Copy link
Member

rwinch commented Sep 13, 2016

I'm closing this in favor of 5ecf390 which uses a property with a default value like:

@Scheduled(cron = "${spring.session.cleanup.cron.expression:0 * * * * *}")

@rwinch rwinch closed this Sep 13, 2016
@rwinch rwinch removed the status: waiting-for-feedback We need additional information before we can continue label Sep 13, 2016
@rwinch rwinch self-assigned this Sep 13, 2016
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.

2 participants