tarmogoyf
tarmogoyf

Reputation: 327

Configuring near cache with Hazelcast

good day everyone

Im trying to use Hazelcast as a local cache in SpringBoot app, following tutorial: https://hazelcast.com/blog/non-stop-client-with-near-cache/

Hazelcast gradle version:

com.hazelcast:hazelcast-client:3.12.11 -> 3.12.10 \

In my version I see no method to set up max timeout for connection to cluster (setClusterConnectTimeoutMillis()):

HazelcastInstance member = Hazelcast.newHazelcastInstance();

ClientConfig config = new ClientConfig();
config.getConnectionStrategyConfig().setReconnectMode(ClientConnectionStrategyConfig.ReconnectMode.ASYNC);
config.getConnectionStrategyConfig().getConnectionRetryConfig().setClusterConnectTimeoutMillis(Integer.MAX_VALUE);

NearCacheConfig nearCacheConfig = new NearCacheConfig("map");
config.addNearCacheConfig(nearCacheConfig);

HazelcastInstance client = HazelcastClient.newHazelcastClient(config);

.. and withought it it falls with

com.hazelcast.client.HazelcastClientOfflineException: Client connecting to cluster

Any alternative to set up it by java config in my Hazelcast version ?

Upvotes: 1

Views: 1579

Answers (1)

Zap
Zap

Reputation: 36

Alternatives to client near-cache setup is using declarative in hazelcast-client.xml or yaml files. Near Cache can also be configured for members using their xml or yaml file.

See... https://github.com/hazelcast/hazelcast-code-samples/blob/master/clients/client-near-cache/src/main/resources/hazelcast-client.xml

Also docs... https://docs.hazelcast.com/imdg/latest/performance/near-cache.html#near-cache-example-for-imap

Upvotes: 1

Related Questions