@gabliam/amqp

amqp plugin for gabliam

Usage no npm install needed!

<script type="module">
  import gabliamAmqp from 'https://cdn.skypack.dev/@gabliam/amqp';
</script>

README

Build Status NPM version

Gabliam amqp

Gabliam plugin for add amqp.

How to use

Installation

$ yarn add @gabliam/amqp

Register plugin

In your main, add amqp plugin

import 'reflect-metadata';
import path from 'path';
import { Gabliam } from '@gabliam/core';
import amqpPlugin from '@gabliam/amqp';

new Gabliam({
  scanPath: __dirname,
  config: path.resolve(__dirname, '../config'),
})
  .addPlugins(amqpPlugin)
  .buildAndStart();

Create a controller

import { RabbitController, RabbitListener, RabbitConsumer } from '@gabliam/amqp';
@RabbitController()
export class HelloRabbitMq {
  

  @RabbitListener('logHi')
  async logHi() {
    console.log('hi');
  }

  @RabbitConsumer('hello')
  async hello(@Content('name') name: string ) {
    return `hello ${$name}`
  }
}

Configuration

Configuration for this plugin is in application.amqp

You can add just one connection configuration or an array of connections configurations

Connection configuration

| key | type | required | default | description | |--|--|--|--|--| | name | string | | default | name of the connection | | url | string | X | | url of the rabbitmq | | undefinedValue | string | | $__##UNDEFINED##__$ | value that's send when content is undefined | | queues | Map of queue configuration | X | | Map of queues |

Queue configuration

| key | type | required | default | description | |--|--|--|--|--| | queueName | string | X | | name of the queue | | options.exclusive | boolean | | false | if true, scopes the queue to the connection (defaults to false) | | options.durable | boolean | | false | if true, the queue will survive broker restarts, modulo the effects of exclusive and autoDelete; this defaults to true if not supplied, unlike the others | | options.autoDelete | boolean | | false | if true, the queue will be deleted when the number of consumers drops to zero (defaults to false) |

License

MIT