hhstore / blog

My Tech Blog: about Mojo / Rust / Golang / Python / Kotlin / Flutter / VueJS / Blockchain etc.
https://github.com/hhstore/blog/issues
294 stars 24 forks source link

NATS: Cloud Native Messaging System #349

Open hhstore opened 2 years ago

hhstore commented 2 years ago

related:

hhstore commented 2 years ago

NATS: 高性能消息队列中间件

官方:

what-is-nats:

server:

client:

应用场景:

特性:

幂等: 在 JetStream 中最多可以使用一次,至少一次,并且恰好一次。

持久性:

监控:

第三方集成:

核心架构:

subjects:

pubsub:

reqreply:

image

queue:

JetStream:

hhstore commented 2 years ago

ref:

nats + 服务发现:

NATS 性能数据:

hhstore commented 2 years ago

SRE:

部署:

docker:


docker pull nats:2.7-alpine3.15

docker run -p 4222:4222 -ti nats:latest

docker run -p 4222:4222 -p 8222:8222 -p 6222:6222 --name nats-server -ti nats:latest

docker-compose:


version: '3.5'

services:
  nats:
    image: nats:2.7-alpine3.15
    container_name: nats
    restart: always
    ports:
      - '4222:4222'
      - '6222:6222'
      - '8222:8222'
    networks:
      - nats_net

# 自定义网络:
networks:
  nats_net:
version: '2'

services:
  nats:
    image: docker.io/bitnami/nats:2
    ports:
      - '4222:4222'
      - '6222:6222'
      - '8222:8222'

监控 & UI:

监控:

UI 搜索:

nats ui

grafana:

hhstore commented 2 years ago

NATS 开发:

发送消息:

接收消息:

监听连接:

参考示例:

hhstore commented 2 years ago

NATS 作为服务发现中间件:

go-micro + NATS + registry:

hhstore commented 2 years ago

使用案例:

hhstore commented 2 years ago

1