NATS

The NATS is a simple, high performance open source messaging system.

Installation

Before we start, we have to install required package:


$ npm i --save nats

Overview

In order to switch to NATS transporter, we need to modify an options object passed to the createMicroservice() method.

main.ts
JS TS
TypeScript

const app = await NestFactory.createMicroservice(ApplicationModule, {
  transport: Transport.NATS,
  options: {
    url: 'nats://localhost:4222',
  },
});

Options

There are a bunch of available options that determine a transporter behavior. They are well-described here. Also, there is an additional queue property which allows you specifying a name of the queue that your server should subscribe to (leave undefined if you don't want use any particular queue)

  • NATS
  • Installation
  • Overview
  • Options

Support us

Nest is an MIT-licensed open source project. It can grow thanks to the support by these awesome people. If you'd like to join them, please read more here.

Principal Sponsor

Sponsors / Backers