javaspringsessionhazelcastsession-replication

Hazelcast Session Replciation With Spring Boot


Am following this documentation for Hazelcast based session replication in a Spring Boot APP.

http://docs.spring.io/spring-session/docs/current/reference/html5/guides/hazelcast-spring.html

The code works fine when a local Hazelcast node gets created from spring boot however what i need is a Hazelcast client code to connect to standalone cluster and do the replication and return back the Session ID as a header in "x-auth-header " field.

Client code is something like this

   ClientConfig clientConfig = new ClientConfig();
    clientConfig.getGroupConfig().setName("dev").setPassword("dev-pass");
    clientConfig.getNetworkConfig().addAddress("x.x.x.x");

I am able to get it working with a WEB Filter but it stores the value as cookie and what i need is the header strategy to work.

I couldn't find any documenation or help to acheive it using a Hazelcast client. Can some one please guide me on how to do it.

Thanks Aravind


Solution

  • Do you have

    @Bean
    public HeaderHttpSessionStrategy sessionStrategy() {
      return new HeaderHttpSessionStrategy();
    }
    

    If everything else is working, this should be all you need