Skip to content

Latest commit

 

History

History
60 lines (48 loc) · 1.46 KB

README.md

File metadata and controls

60 lines (48 loc) · 1.46 KB

NATS JetStream Example Environment

A simple docker-compose environment to bring up a NATS JetStream environment to play with.

Some golang JetStream example code copied from: https://github.com/shijuvar/go-distsys

Bring up Environment

docker compose up -d

This will bring up:

The prometheus targets and grafana datasource and dashboards should be automatically provisioned.

The NATS JetStream dashboard should look something like this:
Nats JetStream Grafana Dashboard

Publish messages and subscribe to streams

Run the go publisher:

cd create-order
go run main.go

Run the order-review subscriber (subscribes to ORDERS.created and publishes ORDERS.approved messages)

cd monitor
go run main.go

Run the monitor subscriber (simply subscribes to all subjects in the ORDERS stream)

cd monitor
go run main.go

Open up the NATS CLI

Open up the NATS cli:

docker run -ti --network go-nats_nats natsio/nats-box

Some useful commands:

nats -s nats account info
nats -s nats stream ls
nats -s nats stream ORDERS
nats -s nats stream view ORDERS
nats -s nats stream info ORDERS
nats -s nats stream view ORDERS 2
nats -s nats consumer info ORDERS monitor
nats -s nats consumer info ORDERS order-review
nats -s nats stream rm ORDERS