Hazelcast IMDG is a distributed in-memory object store and compute engine that supports a wide variety of data structures such as Map, Set, List, MultiMap, RingBuffer, HyperLogLog.
Use Hazelcast IMDG to store your data in RAM, spread and replicate it across a cluster of machines, and perform data-local computation on it.
Hazelcast is:
- cloud and Kubernetes friendly
- often used as a Distributed Cache amongst other use cases
- The HazelcastInstance bean is initialized lazily by Quarkus, if you want eager initialization, make sure to double-check Quarkus Documentation.
You can add the hazelcast-client
extension to your Quarkus project by adding the following dependency:
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>quarkus-hazelcast-client</artifactId>
<version>1.0.0-RC3</version>
</dependency>
The extension exposes a single native-mode-compatible Hazelcast Client bean (HazelcastInstance
) which can be directly injected into your beans:
@Inject
HazelcastInstance hazelcastClient;
By default, client will try to connect to a Hazelcast instance running on the host using port 5701.
Defaults can be customized using application.properties
entries such as:
quarkus.hazelcast-client.cluster-name
quarkus.hazelcast-client.cluster-members
quarkus.hazelcast-client.outbound-port-definitions
quarkus.hazelcast-client.outbound-ports
quarkus.hazelcast-client.labels
quarkus.hazelcast-client.connection-timeout
All of them mirror standard Hazelcast Client configuration options.
If you need more, use a standard hazelcast-client.yml/hazelcast-client.xml
-based configuration (described below) or wire-up your own HazelcastInstance
bean.
Keep in mind that you will still be able to benefit from GraalVM compatibility!
In order to configure the client using the hazelcast-client.yml
file, place the configuration file in the src/main/resources
directory.
Configuration entries from hazelcast-client.yml
override all quarkus.hazelcast-client.*
entries.
To make testing simple, the extension provides the HazelcastServerTestResource
which automatically launches an embedded Hazelcast instance with defaults settings and manages its lifecycle:
@QuarkusTest
@QuarkusTestResource(HazelcastServerTestResource.class)
public class HazelcastAwareTest {
@Test
public void test() {
// you can safely call embedded Hazelcast instance from here
}
}
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-test-hazelcast</artifactId>
<scope>test</scope>
</dependency>
- Default Java serialization is not supported
- User code deployment is not supported
- Hazelcast SPI support can be limited on OSGi