Skip to content

Instantly share code, notes, and snippets.

@bilalkaun
Created December 2, 2020 23:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bilalkaun/eb6f4ab718ae208a881d70e061520514 to your computer and use it in GitHub Desktop.
Save bilalkaun/eb6f4ab718ae208a881d70e061520514 to your computer and use it in GitHub Desktop.
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