Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

env-rmq

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

env-rmq

PubSub, Queue, RPC wrapper for RabbitMQ

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

RabbitMQ wrapper for PubSub, RPC, Queue based on official examples for amqplib

Init

const RabbitMQ = require('env-rmq').RabbitMQ;

const rmq = new RabbitMQ({
	uri: 'amqp://user:password@localhost/'
});
rmq.connect().then(() => {
	console.log('Ready.');
}).catch(err => {
	console.log('Error: ', err);
});

Queue

Worker - handle task

rmq.worker('my-queue-name', function (msg, reject, ack) {
	ack();
});

Client - send task

// Assert channel on application loading
rmq.worker('my-queue-name');

// Send task everywhere
rmq.worker('my-queue-name').send({
	someField: "Hello world!"
});

PubSub

Listener

rmq.pubsub('my-pub-name', function (msg, reject, ack) {
	ack();
});

Sender

// Assert channel on application loading
rmq.pubsub('my-pub-name');

rmq.pubsub('my-pub-name').send({
	someField: "Hello world!"
});

RPC

Server

rmq.rpc('my-function', function (msg, reject, ack) {
	ack({
		returnValue:"OK!"
	});
});

Client

// Assert channel on application loading
rmq.rpc('my-function');

rmq.rpc('my-function').call({
	someField: "Hello world!"
}).then(result => {
	console.log("RETURNED VALUE:", result);
});

Keywords

FAQs

Package last updated on 02 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc