➜ nestjs-plugins git:(master) npm install
➜ nestjs-plugins git:(master) npx lerna run build
➜ nestjs-plugins git:(master) npx lerna run start
- docker desktop 을 실행한다.
docker run -d --name nats-main -p 4222:4222 -p 6222:6222 -p 8222:8222 nats -js -m 8222
- request: GET 127.0.0.1:3001/create
- response: order created.
- nats-listener 에서 console 에 출력한
received: 이벤트명
이 출력되는 것을 확인한다.
{ stream: 'mystream', seq: 2, duplicate: false }
MsgHdrsImpl {
_code: 0,
_description: '',
headers: Map(2) {
'x-custom-header' => [ 'custom-header-value' ],
'Nats-Expected-Stream' => [ 'mystream' ]
}
}
{
domain: '',
account_hash: '',
stream: 'mystream',
consumer: 'myservice-durable-order_created',
redeliveryCount: 1,
redelivered: false,
streamSequence: 2,
deliverySequence: 2,
timestampNanos: 1705985034459888400,
pending: 0
}
received: order.created { id: 1, product: 'NestJS', quantity: 10 }