OpenJ / Libraries / GossipLet nodes find each other

Let a cluster learn its shape.

Teknek Gossip is a Java library for membership, liveness, and eventually consistent data sharing. Nodes exchange their local view until the cluster converges.

Membership without a coordinator

Each node has a URI and seed members. Seeds provide first contact; after startup, nodes learn the rest of the cluster through gossip and expose live and dead member views.

GossipManager manager = GossipManagerBuilder.newBuilder()
    .cluster("example-cluster")
    .uri(new URI("udp://127.0.0.1:50001"))
    .id("node-1")
    .gossipMembers(seedMembers)
    .listener((member, state) ->
        System.out.println(member + " is " + state))
    .build();
manager.init();
>> converges nodes discover membership and report liveness changes

Share state that can merge

Shared data is for values the cluster should converge on. Per-node data is for facts owned by one node. CRDTs make concurrent updates mergeable instead of turning every update into a coordination problem.

SharedDataMessage message = new SharedDataMessage();
message.setKey("cluster/features");
message.setPayload(new OrSet<>("jq4", "gpu"));
manager.merge(message);

// OrSet, GrowOnlyCounter, PNCounter, and more

Use it in a service

The Spring Boot starter loads the same settings model and exposes HTTP gossip endpoints. A service can move from local UDP nodes to HTTP while keeping cluster state and CRDT behavior.

gossip.settings-location=file:node-a.json

POST /gossip/message
GET  /gossip/status

Add the base module

The published base module is io.teknek.gossip:gossip-base:0.1.4. See it on Maven Central, inspect the base POM, or browse the examples and Spring starter.

<dependency>
  <groupId>io.teknek.gossip</groupId>
  <artifactId>gossip-base</artifactId>
  <version>0.1.4</version>
</dependency>

Useful when: Java services need lightweight membership and convergent shared state without a central coordinator for every node view.