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

itp-amqp-node

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

itp-amqp-node

A lightweight AMQP client for Node.js.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

ITP AMPQ Node

NPM version MIT License

A lightweight AMQP client for Node.js

Installation

npm install itp-amqp-node

Example

Producer

const AMQPProducer = require('itp-amqp-node').AMQPProducer;

const producer = new AMQPProducer({
  exchange: 'itp.demo',
  exchange_type: 'topic',
  amqp_uri: process.env.RABBITMQ_URI || 'amqp://localhost'
});

producer.start()
.then(() => {
  console.log('Connected to producer');
}, (err) => {
  console.error('Error while connecting to producer', err);
});

try {
  const routing_key = 'key.hello_world';
  const message = JSON.stringify('Hello World');
  producer.publish(routing_key, new Buffer(message));
} catch (err) {
  console.error('Error while connecting to producer', err);
}

Consumer

const AMQPConsumer = require('itp-amqp-node').AMQPConsumer;

class ConsoleConsumer extends AMQPConsumer {
  handleMessage (msg, resolve, reject) {
    try {
      const jsonMsg = msg.content.toString('utf-8');
      console.log(JSON.parse(jsonMsg));
      resolve();
    } catch (e) {
      console.error(e);
      reject(e);
    }
  }
}

const opts = {
  exchange : 'itp.demo',
  exchange_type : 'topic',
  amqp_uri : process.env.RABBITMQ_URI || 'amqp://localhost',
  routing_key : 'key.hello_world'
};

const ConsoleConsumer = new ConsoleConsumer(opts);
consoleWorker.start();

License

ITP-AMQP-Node is freely distributable under the terms of the MIT license.

Keywords

FAQs

Package last updated on 12 Jul 2016

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