✏️ Formatting
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
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,
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -1,8 +1,6 @@
|
||||
import { logger } from "../utils/logger.utils";
|
||||
|
||||
//RabbitMQ
|
||||
const amqp = require("amqplib/callback_api");
|
||||
|
||||
const rabbitUrl = "amqp://localhost";
|
||||
|
||||
export const sendRabbitMQ = (queueName, data) => {
|
||||
@@ -16,7 +14,6 @@ export const sendRabbitMQ = (queueName, data) => {
|
||||
if (error1) {
|
||||
throw error1;
|
||||
}
|
||||
channel.prefetch(1);
|
||||
const queue = queueName;
|
||||
// Checks for “queueName (updateStock)” queue. If it doesn’t exist, then it creates one.
|
||||
channel.assertQueue(queue, {
|
||||
@@ -31,4 +28,3 @@ export const sendRabbitMQ = (queueName, data) => {
|
||||
}, 500);
|
||||
});
|
||||
};
|
||||
module.exports = sendRabbitMQ;
|
||||
|
||||
Reference in New Issue
Block a user