A lightweight Node.js wrapper around amqplib
to easily publish and consume messages with RabbitMQ using queues.
- Simple API for publishing and consuming messages
- Uses confirm channels for safe delivery
- Queue auto-assertion and JSON encoding
- Ready for use in microservices
npm install https://github.com/AntoineSierzputowski/rabbitmq-client
This package uses dotenv to read the RabbitMQ connection string. Create a .env file in the root of your project (or set the variable directly):
RABBITMQ_URL=amqp://localhost:5672
const { publish, consume } = require('@4vs/rabbitmq-client');
await publish('my-queue', { message: 'Hello, RabbitMQ' });
await consume('my-queue', async (data) => {
console.log('Received:', data);
});
node node_modules/@4vs/rabbitmq-client/test.js