Hi.
I am struggling to understand the problem and unfortunately i couldn't find what can cause it.
My producer:
console.log("Trying to connect")
amqp.connect('amqp://localhost', function(err, conn) {
if (err) {
console.log(err)
} else {
console.log("Managed connecting.. Trying to create a channel")
}
conn.createChannel(function(err, ch) {
var q = 'hello';
ch.assertQueue(q, {durable: false});
channel = ch
var msg = 'helloworld'
for (let i = 0 ; i < 50000; i++) {
msg.start = Date.now()
channel.sendToQueue('hello', new Buffer(JSON.stringify(msg)), {noAck: true});
console.log(" [x] Sent %s", msg);
}
console.log("Finish sending")
});
});
My consumer:
amqp.connect('amqp://localhost', function(err, conn) {
conn.createChannel(function(err, ch) {
var q = 'hello';
ch.assertQueue(q, {durable: false});
console.log(" [*] Waiting for messages in %s. To exit press CTRL+C", q);
ch.consume(q, function(msg) {
const jsonMsg = JSON.parse(msg.content.toString())
console.log(" [x] Received %s, Time: %s", jsonMsg, (Date.now() - jsonMsg.start));
}, {noAck: true});
});
});
The problem is that only when the loop of sending is finished i see the cosumer is getting the message. The consumer is running on different nodejs server and i expect this to be non-blocking.
Tried to find any similar issues but couldn't find real answer.
Please advise
Thanks
Hi.
I am struggling to understand the problem and unfortunately i couldn't find what can cause it.
My producer:
My consumer:
The problem is that only when the loop of sending is finished i see the cosumer is getting the message. The consumer is running on different nodejs server and i expect this to be non-blocking.
Tried to find any similar issues but couldn't find real answer.
Please advise
Thanks