A Java examples for the NATS messaging system.
These Java examples of using the NATS Java client nats.java project
In addition to this repository, there are also more examples in the examples directory of the NATS Java client project.
There is also NATS by Example - An evolving collection of runnable, cross-client reference examples for NATS. The nats-by-example directory contains the same examples.
The starters projects are provided to give you a jump start to adding the NATS Java client to your project.
- starter-maven pom.xml for maven users
- starter-gradle-groovy build.gradle for gradle users who like the Groovy DSL
- starter-gradle-kotlin build.gradle.kts for gradle users who like the Kotlin DSL
As a side note for Kotlin users, there is a small example in the kotlin-nats-examples project.
The Hello World examples does things like create streams, publish and subscribe.
The Core Request Reply is an example demonstrating that using core nats, there are multiple ways to do request reply.
The JS Multi Tool is a tool to assist exercising and benchmarking of the NATS Java client in your own environment.
The files in the Example Dev Cluster Configs directory are templates for building a simple dev cluster.
The OCSP project has instructions and examples for building a OCSP aware SSL Context.
The SSL Context Factory example demonstrates how to implement the SSLContextFactory, an alternative way to provide an SSL Context to the Connection Options.
The Auth Callout example demonstrates a basic Auth Callout handler
The Recreate Consumer example demonstrates creating a durable consumer that will start where another one left off.
The Robust Push Subscription is an application with more robust error handler including recreating the consumer if heartbeat alarm occurs.
The Encoding project has examples that encoded/decode message payload.
The Chain Of Command example shows subscribing with wildcard subjects to form a chain of command. Both "publish style" and "request style" workflow are demonstrated.
The "publish style" does not know if messages were received. The "request style" knows if the request was received, so it could handle the case when it is not.
The Manual File Transfer project was a proof of concept project was done as part of the design of Object Store.
The File Transfer Object Store project demonstrates transferring a file using the completed Object Store API.
The Error and Heartbeat Experiments project are experiments to demonstrate how heartbeats and error listening works.
The Js Over Core uses core nats to publish (with Publish Acks!) and subscribe.
The Server Pool is an example how the developer can provide the connection/reconnection info themselves / dynamically.
The Multi Subject Worker is an example that processes multiple subjects.
The Original Functional Examples where the original examples for the JNATS client and demonstrate one feature at a time.
Unless otherwise noted, the NATS source files are distributed under the Apache Version 2.0 license found in the LICENSE file.