marcelog / rabbitmq_minionpool

minionpool that uses rabbitmq to inject tasks
2 stars 0 forks source link

Ability to configure retry queue to not automatically resend message to worker queue #1

Open apveitas opened 10 years ago

apveitas commented 10 years ago

In some cases, if a message was not consumed properly by a worker (i.e. message.reject()) we would like to put the message into the retry queue and not have the minionpool place it back into worker queue (after ttl expires) in the current automatic fashion.

marcelog commented 10 years ago

hello :)

that sounds good, how would that work exactly? would it be enough to set a custom set of options for the retry queue or it would need some extra code to support it?

marcelog commented 10 years ago

btw, have you tried extending the RabbitMqMinionPool class and override any needed methods by your own?

apveitas commented 10 years ago

Hi Marcelo,

RE: btw, have you tried extending the RabbitMqMinionPool class and override any needed methods by your own?

No, I have not yet tried that and that would be an easy thing to do.

Conceptually, the code would look something like this:

RabbitMqMinionPool.prototype.createRetryQueue = function(
  connection, exchangeName, queueName, args, callback
) {
  var args = {};
  var name = this.retryNameFor(queueName);
  var self = this;
  if (this.mqOptions.autoResubmittalToWorkerExchange) {
         args['x-dead-letter-exchange'] = exchangeName;
         args['x-message-ttl'] = this.mqOptions.retryTimeout;
   }
  this.createQueue(connection, name, args, this.retryNameFor(exchangeName), queueName, callback);
};

So to answer your original question, we would just add on additional option 'autoResubmittalToWorkerExchange' and wrap code to set the dlx xchange and ttl on the retry queue (as shown in code above)