Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@meowwolf/amqp-0.9.1-client

Package Overview
Dependencies
Maintainers
16
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@meowwolf/amqp-0.9.1-client

AMQP 0-9-1 Broker Client

latest
npmnpm
Version
1.0.9
Version published
Maintainers
16
Created
Source

@meowwolf/amqp-0.9.1-client

A simple amqp client that facilitates publishing and subscribing to an amqp v0.9.1 RabbitMQ broker.

Installation

$ npm i @meowwolf/amqp-0.9.1-client

Usage

Import the module:

import { createRabbitMqClient } from '@meowwolf/amqp-0.9.1-client'
// or
const { createRabbitMqClient } = require('@meowwolf/amqp-0.9.1-client')

Create an amqpClient:

const amqpClient = await createRabbitMqClient(amqpConfig, exchangeConfig)

/*
AmqpConfig {
  host: string
  port: number
  username: string
  password: string
  appId?: string - default: '@meowwolf/amqp-0.9.1-client'
  vhost?: string - default: '/'
  tls?: boolean - default: false
  prefetch?: number - default: 0
  autoReconnect?: boolean - default: true
  retryConnectionInterval?: number in ms - default: 5000
}

ExchangeConfig {
  exchangeName?: string - default: 'amq.direct'
  type?: 'direct' | 'fanout' | 'topic' | 'header' - default: 'direct'
  durable?: boolean - default: false
  autoDelete?: boolean
}
*/

Consume amqp messages

addConsumer() expects an argument object consisting of a configuration object and a callback

await amqpClient.addConsumer({
  queueConfig,
  callback: message => {
    // .. do somethig with the message here
  },
})

/*
QueueConfig {
  queueName?: string - default: ''
  routingKey?: string | string[] - default: ''
  exclusive?: boolean - default: true
  durable?: boolean - default: false
  autoDelete?: boolean - default: true
  noAck?: boolean - default: true
}
*/

Acknowledge amqp message

amqpclient.ack(message)

Publish a message

amqpClient.publish(payloadString, publishOptions)

/*
PublishOptions {
  exchangeName?: string - defaults to exchangeConfig value
  routingKey?: string | string[] - default: ''
  correlationId?: string - default: ''
  headers?: GenericObject - default: {}
}
*/

Publish a message directly to a queue

amqpClient.sendToQueue(payloadString, sendToQueueOptions)

/*
SendToQueueOptions {
  queueName: string
  correlationId?: string - default: ''
  headers?: GenericObject - default: {}
}
*/

FAQs

Package last updated on 24 Jul 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