Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Setting Timeout in JDBCSession From Properties
@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