Skip to content

Latest commit

 

History

History

amqp-client

Folders and files

README.md

Use CloudAMQP from JavaScript

A minimal JavaScript example of publishing and consuming messages with amqp-client.js, against CloudAMQP or any AMQP 0-9-1 broker such as LavinMQ or RabbitMQ.

  • publisher.js publishes a persistent message and waits for the broker's confirm.
  • worker.js consumes with a prefetch of 10, acking each message when the callback returns.
  • amqp.js connects using the BROKER_URL environment variable, and reconnects automatically.

Usage

Tool versions are in mise.toml; install them with mise, or use Node.js 24.2+.

npm install
export BROKER_URL="amqps://user:password@host/vhost"
node worker.js      # in one terminal
node publisher.js   # in another

Without BROKER_URL it connects to amqp://guest:guest@localhost.

Tests

npm test publishes and consumes a message through a real broker on localhost. CI runs it against LavinMQ.