Skip to content

mateothegreat/nestjspro-amqp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AMQP for Nest.js like a boss. 💪

asciicast

🧰 Features

  • Configurable as a module + programatically add connections on the fly.
  • 100% Rxjs based with typings.
  • Supports multiple connections.
  • Auto-magic reconnection. 🙏
  • Configurable, verbose, logging facility.
  • Pub/sub + RPC support.
  • Demo implementation.
  • Hackable and extensible.

Installation

npm install @nestjs.pro/amqp
import { Module } from '@nestjs/common';
import { AppService } from './AppService';
import { AMQPModule } from '@nestjs.pro/amqp/dist/AMQPModule';
import { AMQPLogLevel } from '@nestjs.pro/amqp/dist/AMQPLogLevel';

@Module({

    imports: [

        AMQPModule.forRoot({

            logLevel: AMQPLogLevel.DEBUG,
            connections: [

                {

                    name: 'one',
                    uri: 'amqp://rabbitmq:rabbitmq@localhost:5672',
                    exchange: {

                        name: 'test-1',
                        type: 'topic',
                        options: {

                            durable: true

                        }

                    },
                    queues: [

                        {

                            name: '1',
                            routingKey: '111',
                            createBindings: true,
                            options: {

                                durable: false

                            }

                        }

                    ]

                }, {

                    name: 'two',
                    uri: 'amqp://rabbitmq:rabbitmq@localhost:5672',
                    exchange: {

                        name: 'test-2',
                        type: 'topic',
                        options: {

                            durable: true

                        }

                    },
                    queues: [

                        {

                            name: '2',
                            routingKey: '222',
                            createBindings: true,
                            options: {

                                durable: false

                            }

                        }

                    ]

                }

            ]

        })

    ],

    providers: [ AppService ]

})
export class AppModule {
}
                    __    _                       
   ____  ___  _____/ /_  (_)____  ____  _________ 
  / __ \/ _ \/ ___/ __/ / / ___/ / __ \/ ___/ __ \
 / / / /  __(__  ) /_  / (__  ) / /_/ / /  / /_/ /
/_/ /_/\___/____/\__/_/ /____(_) .___/_/   \____/ 
                   /___/      /_/                 

https://github.com/nestjspro