primer cambio
This commit is contained in:
24
node_modules/amqplib/examples/tutorials/emit_log.js
generated
vendored
Normal file
24
node_modules/amqplib/examples/tutorials/emit_log.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const amqp = require('amqplib');
|
||||
|
||||
const exchange = 'logs';
|
||||
const text = process.argv.slice(2).join(' ') || 'info: Hello World!';
|
||||
|
||||
(async () => {
|
||||
let connection;
|
||||
try {
|
||||
connection = await amqp.connect('amqp://localhost');
|
||||
const channel = await connection.createChannel();
|
||||
await channel.assertExchange(exchange, 'fanout', { durable: false });
|
||||
channel.publish(exchange, '', Buffer.from(text));
|
||||
console.log(" [x] Sent '%s'", text);
|
||||
await channel.close();
|
||||
}
|
||||
catch (err) {
|
||||
console.warn(err);
|
||||
}
|
||||
finally {
|
||||
if (connection) await connection.close();
|
||||
};
|
||||
})();
|
||||
Reference in New Issue
Block a user