const amqp = require('amqplib/callback_api'); amqp.connect('amqp://127.0.0.1', (err, connection) => { if (err) { throw err; } connection.createChannel((err, channel) => { if (err) { throw err; } const exchange = 'logs'; const msgTypes = ['Order Received', 'User Message', 'Generate Report']; channel.assertExchange(exchange, 'fanout', { durable: false }); setInterval(() => { const msg = msgTypes[Math.floor(Math.random() * msgTypes.length)]; channel.publish(exchange, '', Buffer.from(msg)); console.log(" [x] Sent '%s'", msg); }, 1000); }); });