@meowwolf/amqp-0.9.1-client
TypeScript icon, indicating that this package has built-in type declarations

1.0.9 • Public • Published

@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: {}
}
*/

Readme

Keywords

none

Package Sidebar

Install

npm i @meowwolf/amqp-0.9.1-client

Weekly Downloads

0

Version

1.0.9

License

ISC

Unpacked Size

27 kB

Total Files

17

Last publish

Collaborators

  • ckahle33
  • mw-npm-sa
  • tmartinez-mw
  • jlondon
  • mstark-mw
  • erincor
  • kdo_
  • deborahgarnmw
  • tmiles_mw
  • msumpter
  • dsanderson_mw
  • btempchin
  • jcarrington
  • geetjacobs
  • lbmw
  • jmorrisonmw
  • conorpteterson
  • it-licensing