rabbitmq-event-manager icon indicating copy to clipboard operation
rabbitmq-event-manager copied to clipboard

Requeue Messages

Open MrFabio opened this issue 5 years ago • 1 comments

Hi.

According to the documentation:

You can "negatively acknowledge" and Requeue the message by returning false (rejecting the Promise).

but that is not working at the moment. Something happened in the src/adapter/helper/consume.ts file in #10 (3df615b3d11c40c0b903f972a6ca4ec245bc782d) because that code was removed.

In the demo/cloudamqp/run.ts demo file :

function consumer() {
  eventManagerConsumer.on('PRODUCER.EVENT', async (payload: any) => {
    console.log('message received', payload);
    switch (payload.action) {
      case 'FLUSH':
        throw new Error('Flush Message');
      case 'REQUEUE':
        return false;
      case 'ACK':
      default:
        return true;
    }
  });
}

there is the requeue option but that is not working.

So how do I use the requeue feature and maxNumberOfMessagesRetries ? Is the requeue deprecated and I should use the dlx to "requeue" the message to the same exchange ?

Using rabbitmq-event-manager: 1.2.0.

MrFabio avatar Jun 15 '20 16:06 MrFabio

Hi, You are right the documentation is not up-to-date, I will update it. The "REQUEUE" option has been deprecated. If you want to requeue the message you will have to use the DLX, but be careful, by default (with this lib) the DLX is the same for all queues, so if you have many events (and so many queues) you may have to write a consumer for dead lettered messages, and route them according to the original queue.

regards

Rémi

mimiz avatar Jun 17 '20 06:06 mimiz