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.jspublishes a persistent message and waits for the broker's confirm.worker.jsconsumes with a prefetch of 10, acking each message when the callback returns.amqp.jsconnects using theBROKER_URLenvironment variable, and reconnects automatically.
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 anotherWithout BROKER_URL it connects to amqp://guest:guest@localhost.
npm test publishes and consumes a message through a real broker on
localhost. CI runs it against LavinMQ.