Answer the question
In order to leave comments, you need to log in
How to pause a RabbitMQ queue?
Hello. After receiving data from rabbmit, it is necessary to pause the receipt of data from the queue.
const amqp = require("amqplib/callback_api");
var connection;
var queueName = "test";
var chanel;
amqp.connect("amqp://localhost", (err, conn) => {
if (err) {
console.log("Error connect");
process.exit();
}
connection = conn;
conn.createChannel((err, ch) => {
chanel = ch;
ch.assertQueue(queueName, {
durable: false
});
ch.consume(queueName, () => {
// тут нужно поставить на паузу. после обработки данных нужно возобновить получение данных
console.log(msg.content.toString());
}, {noAck: false});
});
});
Answer the question
In order to leave comments, you need to log in
Hello. You don't need to pause the queue) This is not architecturally correct.
If you need to process the data and then send the already processed data, then you need another queue.
For example, one augmenter queue that listens to all messages, processes and pushes further to another queue.
And the second, for example, persister, which listens to another queue (augementer) on a different key and does something else with this data (for example, saves it to the database).
As a result:
- you have a weak connection between these logical modules
- if one of the queues falls, the second one will be able to continue processing existing messages
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question