nest-microservices-messaging

0.0.3 • Public • Published

nest-microservices-messaging

How to use

  • install package with npm i -S nest-microservices-messaging
  • Register the MessagingModule to your feature modules:
@Module({})
export class AppModule {
  static register(config: ConfigOptions): DynamicModule {
    return {
      module: AppModule,
      imports: [
        MessagingModule.register(config.messagingOptions),
        ...
      ],
    };
  }
}
  • Once MessagingModule is registered, then you can use PublisherService to publish to RabbitMQ
export class ExampleController {
  constructor (private service: PublisherService) {
    super (service, logger);
  }

  await publish () {
    this.publisherService.publish('my-queue', { hello: 'world' });
  }
}

Messaging options

Property Type Required Description
exchanges MessageQueueOptions true Contains { name: string, type: string } which defined the exchange name and type of exchange
uri String true Uri or your RabbitMQ server
connectionInitOptions MessageConnectionOptions true Contains { wait: boolean } for connection resiliency. See https://www.npmjs.com/package/@golevelup/nestjs-rabbitmq for more details

Readme

Keywords

none

Package Sidebar

Install

npm i nest-microservices-messaging

Weekly Downloads

2

Version

0.0.3

License

UNLICENSED

Unpacked Size

7.17 kB

Total Files

11

Last publish

Collaborators

  • jsnmgpnty