🍛 Commit progress before lunch break

This commit is contained in:
steinkirch.eth, phd 2023-07-15 13:01:58 -07:00
parent 4cf49ba50b
commit 9aa9e827c0
19 changed files with 378 additions and 19 deletions

View file

@ -0,0 +1,22 @@
/* RabbitMQ */
const amqp = require("amqplib");
const msg = {number: process.argv[2]}
connect();
async function connect() {
try {
const amqpServer = "amqp://localhost:5672"
const connection = await amqp.connect(amqpServer)
const channel = await connection.createChannel();
await channel.assertQueue("jobs");
await channel.sendToQueue("jobs", Buffer.from(JSON.stringify(msg)))
console.log(`Job sent successfully ${msg.number}`);
await channel.close();
await connection.close();
}
catch (ex){
console.error(ex)
}
}