-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
27 lines (22 loc) · 818 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const amqp = require('amqplib/callback_api');
const fs = require('fs');
const img = './images/baske.png';
const sendTo = 'render_queue';
const replyTo = 'back';
const uvBuffer = fs.readFileSync(img, null).buffer;
const sendingData = new Buffer(uvBuffer);
amqp.connect('amqp://localhost', (err, conn) => {
// Sending channel
conn.createChannel((err, ch) => {
ch.assertQueue(sendTo, { durable: false });
ch.sendToQueue(sendTo, sendingData, { replyTo, correlationId: '1' });
console.log(" [x] Sent %s", uvBuffer);
});
// Receiving channel
conn.createChannel((err, ch) => {
ch.assertQueue(replyTo, { durable: false });
ch.consume(replyTo, msg => {
console.log(" [x] Received %s", msg.content.toString());
}, { noAck: true });
});
});