B
B
betula2014-07-21 14:14:01
Node.js
betula, 2014-07-21 14:14:01

How to write amqp rabbitmq message processing report?

I am writing on node.js, node-amqp driver, let's say the following code:

conn.queue(queueName, function(queue) {
  queue.subscribe(function(msg) {
    performQueueMessage(msg, function(err) {
      // Сообщение обработали, возможно с ошибкой
    });
  });
});

Question:
Is there such a mode of receiving messages so that rabbitmq does not delete a message from itself until I tell it, "I processed it without error" and that it would wait for this answer from me, either until the connection is broken, or n-time. And if I tell him that I "did not process the message", then what would rabbitmq return the message to the active queue again and give it, either again to this client, or to any other.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2014-07-21
Protko @Fesor

You can simply include a message back in the queue by changing its status. There is no other way, and you don’t need it any other way, otherwise it will all result in problems if you have several queue handlers.

B
betula, 2014-07-21
@betula

The task context is this.
Processing of each job from the queue can be very long up to several minutes, there are a lot of jobs. And if the node.js daemon crashes at that moment, I irretrievably lose messages.
Solutions:
1. Log "transactions" on the side of the node.js daemon and keep a log of messages taken for processing, their status, etc., so that when the daemon starts, you can watch incomplete transactions and try to complete them, say, by sending them back to the queue.
2. I am sure that rabbitmq should somehow do the same.
If option 2 is still impossible, then you will have to do with option 1, and wait until rabbitmq implements everything that is so lacking in it.

V
Vladimir, 2014-08-22
@rostel

There is a message processing confirmation mode.
You can start searching from here habrahabr.ru/post/150134

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question