You can configure Hazelcast Java Client declaratively (XML), programmatically (API), or using client system properties.
For declarative configuration, the Hazelcast client looks at the following places for the client configuration file.
System property: The client first checks if
hazelcast.client.configsystem property is set to a file path, e.g.,
-Dhazelcast.client.config=C:/myhazelcast.xml. Please refer to System Properties - Client for the list of client system properties.
Classpath: If config file is not set as a system property, the client checks the classpath for
If the client does not find any configuration file, it starts with the default configuration (
hazelcast-client-default.xml) located in the
hazelcast-client.jar library. Before configuring the client, please try to work with the default configuration to see if it works for you. The default should be just fine for most users. If not, then consider custom configuration for your environment.
If you want to specify your own configuration file to create a
Config object, the Hazelcast client supports the following.
Config cfg = new XmlClientConfigBuilder(xmlFileName).build();
Config cfg = new XmlClientConfigBuilder(inputStream).build();
For programmatic configuration of the Hazelcast Java Client, just instantiate a
ClientConfig object and configure the desired aspects. An example is shown below.
ClientConfig clientConfig = new ClientConfig(); clientConfig.setGroupConfig(new GroupConfig("dev","dev-pass”); clientConfig.setLoadBalancer(yourLoadBalancer); ... ...