Tobi
Tobi

Reputation: 171

Spring session with Hazelcast is still stored in InMemoryWebSessionStore

I'm developing spring boot application. I want to store my session to Hazelcast. I followed this guide. Since I already have hazelcast standalone, I want to use Hazelcast client instead of the embedded one. Here the bean to provide hazelcastInstance.

@Bean
@SpringSessionHazelcastInstance
public HazelcastInstance hazelcastInstance() {
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.getNetworkConfig().addAddress("127.0.0.1:5701");
    clientConfig.setClusterName(HAZELCAST_CLUSTER_NAME);
    clientConfig.getUserCodeDeploymentConfig().setEnabled(true).addClass(Session.class)
                .addClass(MapSession.class).addClass(Hazelcast4SessionUpdateEntryProcessor.class);
    return HazelcastClient.newHazelcastClient(clientConfig);
}

However, when I check on Hazelcast console, no session is stored there. It's always stored in the InMemoryWebSessionStore.

Most of the guides I found, they used hazelcast embed instead of the client one. Is my implementation wrong? Anyone have better solution?

I also set spring.session.store-type=hazelcast in application.properties.

Thanks.

Upvotes: 0

Views: 627

Answers (1)

Marcus Hert da Coregio
Marcus Hert da Coregio

Reputation: 6258

You probably need @EnableHazelcastHttpSession, see here https://docs.spring.io/spring-session/reference/http-session.html#security-spring-configuration

Upvotes: 0

Related Questions