Skip to content

Simple queueing package for task queueing using rabbitmq

License

Notifications You must be signed in to change notification settings

saularis/rabbitmqueue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RabbitMQueue

Node.js CI

Simple queueing package for task queueing using rabbitmq

Prerequisite

Install and start rabbitmq. Here's the link to download and installation guide.

Installation

npm i rabbitmqueue

Queue Daemon

Create a js file on the root directory of your project. Let's call it rmq.js.

const rabbitmqueue = require('rabbitmqueue');

const consumers = {
    'default': function (data) {
        console.dir(data);
    }
};

rabbitmqueue.init("amqp://localhost", consumers);

Here consumers is an object containing queue names as key and job handling function as value.

We initialize the daemon using init where you must pass rabbitmq connection string and consumer object.

Start Daemon

node rmq.js

We can use PM2 on production.

Producer in action

Here's how to push messages to queue.

const rabbitmqueue = require('rabbitmqueue');

const producer = rabbitmqueue.producer("amqp://localhost", ['default']);

producer.produce('default', {
    'key1': 'value1',
    'key2': 'value2'
});

About

Simple queueing package for task queueing using rabbitmq

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published