Skip to content

Instantly share code, notes, and snippets.

@Scheduled(cron = "${spring.session.cleanup.cron.expression:0 * * * * *}")
public void cleanupExpiredSessions() {
this.expirationPolicy.cleanExpiredSessions();
}
public void cleanExpiredSessions() {
long now = System.currentTimeMillis();
long prevMin = roundDownMinute(now);
if (logger.isDebugEnabled()) {
logger.debug("Cleaning up sessions expiring at " + new Date(prevMin));
}
String expirationKey = getExpirationKey(prevMin);
Set<Object> sessionsToExpire = this.redis.boundSetOps(expirationKey).members();
public class RedisOperationsSessionRepository implements
FindByIndexNameSessionRepository<RedisOperationsSessionRepository.RedisSession>,
MessageListener {
...
@SuppressWarnings("unchecked")
public void onMessage(Message message, byte[] pattern) {
byte[] messageChannel = message.getChannel();
byte[] messageBody = message.getBody();
if (messageChannel == null || messageBody == null) {
return;
@Configuration
@EnableScheduling
public class RedisHttpSessionConfiguration extends SpringHttpSessionConfiguration
implements EmbeddedValueResolverAware, ImportAware {
@Bean
public RedisMessageListenerContainer redisMessageListenerContainer(
RedisConnectionFactory connectionFactory,
RedisOperationsSessionRepository messageListener) {
@EnableRedisHttpSession
public class RedisOperationsSessionRepositoryConfigNoOp {
/**
* Avoid changing Redis configuration for publishing specific events (gxE)
* (see EnableRedisKeyspaceNotificationsInitializer - overrides ConfigureNotifyKeyspaceEventsAction which setting default event configuration )
* @return
*/
@Bean
public static ConfigureRedisAction configureRedisAction() {
return ConfigureRedisAction.NO_OP;
@EnableRedisHttpSession
public class RedisOperationsSessionRepositoryConfigNoListener {
/**
* Prevent server from subscription to Redis events (see RedisHttpSessionConfiguration)
* @param connectionFactory
* @param messageListener
* @return
*/
@Bean
@EnableRedisHttpSession
public class RedisOperationsSessionRepositoryConfigNoListener {
@Bean
public RedisMessageListenerContainer redisMessageListenerContainer(
RedisConnectionFactory connectionFactory,
RedisOperationsSessionRepository messageListener) {
return new RedisMessageListenerContainer();
}
FROM ubuntu
MAINTAINER Kimbro Staken
RUN apt-get install -y python-software-properties python python-setuptools ruby rubygems
RUN add-apt-repository ppa:chris-lea/node.js
RUN echo "deb http://us.archive.ubuntu.com/ubuntu/ precise universe" >> /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y nodejs
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
@RestController
@Slf4j
class BeerNamesController {
@Output(Source.OUTPUT)
@Autowired
private MessageChannel messageChannel;
@Autowired
RestTemplate restTemplate;
@RestController
@Slf4j
class BeerNamesController {
@Output(Source.OUTPUT)
@Autowired
private MessageChannel messageChannel;
@Autowired
RestTemplate restTemplate;