Coder Social home page Coder Social logo

quarkus-hazelcast-client's Introduction

Hazelcast Client for Quarkus

GitHub Actions status Maven Central

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

See the official guide here.

Features

  • The HazelcastInstance bean is initialized lazily by Quarkus, if you want eager initialization, make sure to double-check Quarkus Documentation.

Configuration

After configuring quarkus-universe BOM:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-universe-bom</artifactId>
            <version>${insert.newest.quarkus.version.here}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

You can just configure the hazelcast-client extension by adding the following dependency:

<dependency>
    <groupId>com.hazelcast</groupId>
    <artifactId>quarkus-hazelcast-client</artifactId>
</dependency>

NOTE: You can bootstrap a new application quickly by using code.quarkus.io and choosing quarkus-hazelcast-client

Quarkus hazelcast-client configuration

The extension exposes a single native-mode-compatible Hazelcast Client bean (HazelcastInstance) which can be directly injected into your beans:

private final HazelcastInstance hazelcastInstance;

public UsersService(HazelcastInstance hazelcastInstance) {
    this.hazelcastInstance = hazelcastInstance;
}

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-members
quarkus.hazelcast-client.outbound-port-definitions
quarkus.hazelcast-client.outbound-ports
quarkus.hazelcast-client.cluster-name
quarkus.hazelcast-client.labels
quarkus.hazelcast-client.connection-timeout

For example:

quarkus.hazelcast-client.cluster-members=localhost:5701

If you don't provide a port number, Hazelcast Client will try to autodetect it:

quarkus.hazelcast-client.cluster-members=localhost

You can also pass a comma-separate list of values as a single entry:

quarkus.hazelcast-client.cluster-members=localhost:5701,localhost:5702

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!

Configuration Files

Configuration using hazelcast-client.yml or hazelcast-client.xml

In order to configure the client using the hazelcast-client.yml/hazelcast-client.xml file, place the configuration file in the src/main/resources directory.

Keep in mind that configuration entries from hazelcast-client.yml/xml are overridden by quarkus.hazelcast-client.* entries so it's a good idea to stick to one of these exclusively.

Testing

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
     }
 }

Maven dependency:

<dependency>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-test-hazelcast</artifactId>
    <scope>test</scope>
</dependency>

Compatibility Matrix

  • 1.0.x is compatible with Quarkus 1.6.x-1.7.x (no longer maintained)
  • 1.1.1 is compatible with Quarkus 1.8.x+ and Hazelcast 4.0.x and 4.1.x
  • 1.2.0 is compatible with Quarkus 1.13.x+ and Hazelcast 4.x

Limitations (native mode)

There's no support for:

  • Default Java serialization
  • User code deployment
  • Hazelcast SPI support on OSGi
  • JCache integration
  • JMX

quarkus-hazelcast-client's People

Contributors

aloubyansky avatar dependabot-preview[bot] avatar dependabot[bot] avatar devopshazelcast avatar ffang avatar pivovarit avatar ppalaga avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.