Socket
Book a DemoInstallSign in
Socket

amqp-simple-connect

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amqp-simple-connect

Simple interface for AMQP library.

2.0.2
latest
npmnpm
Version published
Weekly downloads
2
-91.3%
Maintainers
1
Weekly downloads
 
Created
Source

amqp-simple-connect

Simple wrapper for amqp. Provide only two simple methods: #publish & #subscribe.

Installation

npm install --save amqp-simple-connect

Example

import amqp from 'amqp-simpe-connect'

const config = {
  // url for amqp entrance
  path: 'amqp://dev.rabbitmq.com',
  // exchange name
  exchange: 'test.topic',
}



async function () {
  const testQueueName = 'test_queue';
  
  /* Connect amqp. 
  Amqp-simple-connect is a singletone. In real code you can initialize connection in you main app file. */
  await amqp.connect(config);
  
  // Create queue. You can create as many queues as you want;
  const queue = amqp.createQueue(testQueueName);
  
  // Subscribe to queue.
  queue.subscribe((message, ack) => {
    console.log(message); // => {a: 1}
    
    // acknowledge message;
    ack();
  })
  
  // Publish to queue.
  amqp.publish(testQueueName, {a: 1})
  
  // Close queue connection.
  await queue.close();
}

Keywords

ES6

FAQs

Package last updated on 03 May 2017

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.