mirror of
https://github.com/autistic-symposium/backend-and-orchestration-toolkit.git
synced 2025-06-08 15:02:55 -04:00
22 lines
No EOL
603 B
JavaScript
22 lines
No EOL
603 B
JavaScript
/* 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)
|
|
}
|
|
|
|
} |