const amqp = require("amqplib/callback_api"); export const connectQueue = (socketConnection) => { amqp.connect("amqp://localhost", (error0, connection) => { if (error0) { throw error0; } connection.createChannel((error1, channel) => { if (error1) { throw error1; } const queue = "comicBookCovers"; channel.assertQueue(queue, { durable: false, }); console.log( " [*] Waiting for comic book cover data in %s. To exit press CTRL+C", queue ); channel.consume( queue, (data) => { console.log("data", data); //Socket Trigger All Clients socketConnection.emit("coverExtracted", JSON.parse(data.content.toString())); }, { noAck: true, } ); }); }); };