gcool-info / nats-playground

Playground for a secure, Highly Available NATS Cluster with message persistence (using JetStream)

Home Page:https://gcoolinfo.medium.com/comparing-nats-nats-streaming-and-nats-jetstream-ec2d9f426dc8

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NATS JetStream Playground

Playground for a Secure, Highly Available NATS Cluster with message persistence (using JetStream).

This repo contains a cluster with 3 nodes and a Go client sending/receiving messages to it.

Pre-requisites

To use this repo, please install:

  • Docker
  • mkcert (zero-config tool for locally-trusted development certificates)

Installation

Authentication for client-server and server-server (for the cluster) use X509 certificatesn. To install them locally:

make certificates

Run it

Spin up the cluster with:

docker-compose up

Run the client with:

cd client
go run client.go

You should see the following appear in your terminal:

connecting securely to cluster
getting JetStream context
stream not found
creating stream "ORDERS" and subject "ORDERS.received"
publishing an order
attempting to receive order
got order: "one big burger"

You can also use nats-io/nats-tools/nats to issue manual commands to the cluster. If you do so, you may need to change the client publish permissions in config/jetstream.conf.

Clean up

Once you are done testing, remove the CA from your local system trust store:

make cleanup

About

Playground for a secure, Highly Available NATS Cluster with message persistence (using JetStream)

https://gcoolinfo.medium.com/comparing-nats-nats-streaming-and-nats-jetstream-ec2d9f426dc8

License:MIT License


Languages

Language:Go 80.1%Language:Makefile 19.9%