Using the package in microservices:
const RabbitMQPublisher = require('queue-publisher-package');
const publisher = new RabbitMQPublisher();
async function sendMessageToQueue(queueName, message) { try { await publisher.publishToQueue(queueName, message); } catch (error) { console.error('Failed to send message to queue:', error); // Handle error } }
// Example usage: const message = { key: 'value' }; sendMessageToQueue('myQueue', message);