2014-11-01 1 views
0

그래서 2 개의 노드가있는 Heroku에 스프링 응용 프로그램을 배포하고 장바구니에 제품을 추가하고 장바구니 페이지를 새로 고치기 시작하는 경우 가끔 제품 그곳에 없어. 그래서 요청이 매번 다른 노드를 때리는 것 같아요.Spring Session in Paas 끈적 세션

스프링 세션 웹 사이트에서 This can make clustering much easier. This is nice because the clustering setup is done in a vendor neutral way. Furthermore, in some environments (i.e. PaaS solutions) developers cannot modify the cluster settings easily.을 볼 수 있지만 spring-session으로 끈끈한 세션의 설정 방법을 찾을 수 없습니다. 내 MVC의 설정에서 다음

@Bean(name = { "defaultRedisSessionRepository", "sessionRepository" }) 
@ConditionalOnProperty(name = { "nemesis.platform.redis.url" }) 
public SessionRepository defaultRedisSessionRepository(RedisTemplate<String,ExpiringSession> redisTemplate) throws Exception { 
    return new RedisOperationsSessionRepository(redisTemplate); 
} 

:

@Bean(name = {"defaultSessionFilter", "sessionFilter"}) 
public Filter sessionFilter() { 
    CompositeFilter compositeFilter = new CompositeFilter(); 
    compositeFilter.setFilters(Arrays.asList(new SessionRepositoryFilter(applicationContext.getBean("sessionRepository", SessionRepository.class)), applicationContext.getBean(UrlEncoderFilter.NAME, UrlEncoderFilter.class))); 

    return compositeFilter; 
} 

WebApplicationInitializer에서 다음 :

final FilterRegistration sessionFilterChainReg = servletContext.addFilter("sessionFilter", DelegatingFilterProxy.class); 
    sessionFilterChainReg.addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST, DispatcherType.ERROR, DispatcherType.ASYNC, DispatcherType.FORWARD, DispatcherType.INCLUDE), false, dispatcherServletReg.getName()); 

답변

1

봄 세션하지 않습니다 설치 끈적 내 설정은 상자의 단지 하나 ouf입니다 세션. 대신 모든 JVM이 세션 데이터를 중앙 데이터 저장소 (예 : Redis)에 배치하여 조회 할 수 있습니다.