doc.dev1x.org

NATS.io

1. NATS.ioとは

2. NATSとNATS JetStream

3. KEY-VALUEストア

4. オブジェクトストレージ

5. docker composeで動かしてみる

version: "3.5"
services:
  nats:
    image: nats
    ports:
      - "8222:8222"
    command: "--cluster_name NATS --cluster nats://0.0.0.0:6222 --http_port 8222 "
  nats-1:
    image: nats
    command: "--cluster_name NATS --cluster nats://0.0.0.0:6222 --routes=nats://ruser:T0pS3cr3t@nats:6222"
    depends_on: [ "nats" ]
  nats-2:
    image: nats
    command: "--cluster_name NATS --cluster nats://0.0.0.0:6222 --routes=nats://ruser:T0pS3cr3t@nats:6222"
    depends_on: [ "nats" ]
  nats-cli:
    image: natsio/nats-box
$ docker compose up
$ docker compose run nats-cli nats sub -s nats://nats:4222 hello
$ docker compose run nats-cli nats pub -s nats://nats:4222 hello WORLD
[#1] Received on "hello"
WORLD

6. jetstreamモードで起動する

version: "3.5"
services:
  nats:
    image: nats
    ports:
      - 4222:4222
      - 8222:8222
    command: [
      "--port",
      "4222",
      "--http_port",
      "8222",
      "--jetstream",
      "--store_dir",
      "/data",
      "--debug",
  ]
  nats-cli:
    image: natsio/nats-box

参考資料