Comparing version 0.2.0 to 0.3.0
@@ -253,2 +253,3 @@ 'use strict'; | ||
var _ref9 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9(consumerChannel, queueName, payload, msg) { | ||
var finalQueueName; | ||
return regeneratorRuntime.wrap(function _callee9$(_context9) { | ||
@@ -266,3 +267,4 @@ while (1) { | ||
attemptsLimit: msg.properties.headers.attemptsLimit, | ||
attemptsCount: msg.properties.headers.attemptsCount + 1 | ||
attemptsCount: msg.properties.headers.attemptsCount + 1, | ||
finalQueueOnAttemptsExceeded: msg.properties.headers.finalQueueOnAttemptsExceeded | ||
}); | ||
@@ -274,9 +276,28 @@ | ||
debug('[' + payload.correlationId + '] Requeued job'); | ||
_context9.next = 8; | ||
_context9.next = 16; | ||
break; | ||
case 7: | ||
if (!msg.properties.headers.finalQueueOnAttemptsExceeded) { | ||
_context9.next = 15; | ||
break; | ||
} | ||
finalQueueName = msg.properties.headers.finalQueueOnAttemptsExceeded; | ||
_context9.next = 11; | ||
return _this.sendToQueue(finalQueueName, payload, { | ||
attemptsCount: msg.properties.headers.attemptsCount | ||
}); | ||
case 11: | ||
consumerChannel.nack(msg, false, false); | ||
debug('[' + payload.correlationId + '] Sent job to final queue'); | ||
_context9.next = 16; | ||
break; | ||
case 8: | ||
case 15: | ||
consumerChannel.nack(msg, false, false); | ||
case 16: | ||
case 'end': | ||
@@ -283,0 +304,0 @@ return _context9.stop(); |
@@ -123,3 +123,4 @@ | ||
attemptsLimit: msg.properties.headers.attemptsLimit, | ||
attemptsCount: msg.properties.headers.attemptsCount + 1 | ||
attemptsCount: msg.properties.headers.attemptsCount + 1, | ||
finalQueueOnAttemptsExceeded: msg.properties.headers.finalQueueOnAttemptsExceeded | ||
}) | ||
@@ -131,3 +132,15 @@ | ||
else { | ||
consumerChannel.nack(msg, false, false); | ||
if (msg.properties.headers.finalQueueOnAttemptsExceeded) { | ||
const finalQueueName = msg.properties.headers.finalQueueOnAttemptsExceeded | ||
await this.sendToQueue(finalQueueName, payload, { | ||
attemptsCount: msg.properties.headers.attemptsCount, | ||
}) | ||
consumerChannel.nack(msg, false, false); | ||
debug(`[${payload.correlationId}] Sent job to final queue`); | ||
} | ||
else { | ||
consumerChannel.nack(msg, false, false); | ||
} | ||
} | ||
@@ -134,0 +147,0 @@ } |
{ | ||
"name": "minion-kit", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Toolkit for building tiny workers in a microservice environment using an event bus", | ||
@@ -5,0 +5,0 @@ "main": "dist/", |
647
38605
15