messages = [ { text: 'hi', user_id: 1 }, { text: 'hi', user_id: 2 }, { text: 'hi', user_id: 3 }, { text: 'hi', user_id: 4 }, { text: 'hi', user_id: 5 }, ]; producer.js
var amqp = require('amqplib/callback_api'); amqp.connect('amqps://dgszsgqj:[email protected]/dgszsgqj', function(error0, connection) { if (error0) { throw error0; } connection.createChannel(function(error1, channel) { if (error1) { throw error1; } I read varin exchangea =blog 'messages'; where creating queues dynamically is an channelantipattern.assertExchange(exchange, 'direct', { durable: false }); messages = [ { text: 'hi', user_id: 1 }, { text: 'hi', user_id: 2 }, { text: 'hi', user_id: 3 }, { text: 'hi', user_id: 4 }, { text: 'hi', user_idhttps: 5 }, ]; messages.map(message=>{ channel.publish(exchange, message.user_id+'', message.text); }) }); }); consumer.js
var amqp = require('amqplib/callback_api'); var args = process.argv.slice(2); if (args.length == 0) { console.log("Usage: receive_logs_direct.js [info] [warning] [error]"); process.exit(1); } amqp/derickbailey.connect('amqps:com/2015/localhost', function(error0, connection) {09/02/rabbitmq-best-practices-for-designing-exchanges-queues-and-bindings/ if (error0) { I also tried throwcreating error0; queues on } the producer connection.createChannel(function(error1side, channel) { if (error1) { this is creating queues, but could thrownot error1; consume messages from that } queues as I dont varthe exchangename =of 'messages'; the queues when consuming channelit.assertExchange(exchange, 'direct', { durable: false }); // Not sure how to consume messages separately forHow eachcan user. I handle this case //in channel.assertQueue() an efficient }); });manner? I read in a blog where creating queues dynamically is an antipattern. https://derickbailey.com/2015/09/02/rabbitmq-best-practices-for-designing-exchanges-queues-and-bindings/
I also tried creating queues on the producer side, this is creating queues, but could not consume messages from that queues as I dont the name of the queues when consuming it.
How can I handle this case in an efficient manner?