mirror of
https://github.com/autistic-symposium/backend-and-orchestration-toolkit.git
synced 2025-06-08 15:02:55 -04:00
🍛 Commit progress before lunch break
This commit is contained in:
parent
4cf49ba50b
commit
9aa9e827c0
19 changed files with 378 additions and 19 deletions
22
code/protocol_demos/rabbitmq/publisher.js
Normal file
22
code/protocol_demos/rabbitmq/publisher.js
Normal 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)
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue