8

I am using Spring and Spring Security and want to use spring-session-data-redis with RedisHttpSessionConfiguration to enable storing session IDs on redis (so clients wont loose their sessions when webapp fails and switched over to another server).

My question, what happens when Redis server is down? Will spring be able to continue to work by storing session in memory until Redis is back up? Is there a way to configure this as so?

I am using Redis on AWS ElastiCache, and Failover can take several minutes before replacement primary node is configured on the DNS.

Berethor
  • 261
  • 1
  • 11
  • So the answer is no. If Redis goes down then spring-sesion-data-redis fails and throws an exception. Does anyone know of an implementation that doesn't? with perhaps backup data to in memory map? – Berethor Nov 01 '15 at 10:10
  • I was thinking the same here. Any news on this, please update. – digao_mb Nov 30 '15 at 12:52

1 Answers1

1

As far as I can see, you will need to provide an implementation of CacheErrorHandler ( javadoc).

You can do this by providing a Configuration instance, that implements CachingConfigurer, and overrides the errorHandler() method.

For example:

@Configuration
@Ena1bleCaching
public class MyApp extends SpringBootServletInitializer  implements CachingConfigurer {

  @Override
  public CacheErrorHandler errorHandler() {

    return MyAppCacheErrorHandler();
  }

}

Exactly HOW you will then provide uninterrupted service is not clear to me - without duplicating the current sessions in your failover cache, it seems impossible.

If you are using ElasticCache, is it not possible to have AWS handle a replicated setup for you, so that if one node goes doen, the other can take over?

demaniak
  • 2,987
  • 1
  • 26
  • 32