camaleon-rabbitmq
v1.0.6
Published
RabbitMQ producer/consumer templete using NodeJS and Typescript.
Downloads
3
Readme
camaleon-rabbitmq
camaleon-rabbitmq
is a RabbitMQ abstraction written in TypeScript.
Installing
You can install camaleon-rabbitmq
with npm:
npm install camaleon-rabbitmq
Using
Camaleon RabbitMQ gives you two basic Pub/Sub functionalities: Producers and Subscribers.
Producers
import { ExampleMessage } from '../example.message';
import { IProducer, RabbitProducer } from 'camaleon-rabbitmq';
const brokerAddress = process.env.BROKER_ADDRESS || 'amqp://guest:guest@localhost:5672';
const producer: IProducer = new RabbitProducer(brokerAddress);
const exchangeName = 'example-message';
const message = new ExampleMessage();
producer.produce<ExampleMessage>(exchangeName, message);
You can find more examples of producers at this repository.
Subscribers
import { ExampleHandler } from './example.handler';
import { ExampleMessage } from '../example.message';
import { BrokerStartup, IHandler } from 'camaleon-rabbitmq';
const brokerAddress = process.env.BROKER_ADDRESS || 'amqp://guest:guest@localhost:5672';
const exchangeName = 'example-message';
const broker = new BrokerStartup(
brokerAddress, exchangeName, new ExampleHandler());
broker.Run();
You can find more examples of subscribers at this repository.