Created
December 2, 2020 23:26
-
-
Save bilalkaun/eb6f4ab718ae208a881d70e061520514 to your computer and use it in GitHub Desktop.
Setting Timeout in JDBCSession From Properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
public class JDBCSessionPostConfig | |
{ | |
private final Integer serverTimeout; | |
private final JdbcOperationsSessionRepository jdbcOperationsSessionRepository; | |
private final static int DEFAULT_TIMEOUT_IN_SECONDS = 1800; // 30 minutes | |
public JDBCSessionPostConfig(@Value("${server.session.timeout:"+DEFAULT_TIMEOUT_IN_SECONDS+"}") Integer serverTimeout, | |
JdbcOperationsSessionRepository jdbcOperationsSessionRepository) | |
{ | |
this.serverTimeout = serverTimeout; | |
this.jdbcOperationsSessionRepository = jdbcOperationsSessionRepository; | |
} | |
@EventListener(ApplicationReadyEvent.class) | |
public void setTimeout() | |
{ | |
jdbcOperationsSessionRepository.setDefaultMaxInactiveInterval(serverTimeout); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment