diff --git a/lib/amqp/SubscriberError.js b/lib/amqp/SubscriberError.js index 99353f4..6fb7ba9 100644 --- a/lib/amqp/SubscriberError.js +++ b/lib/amqp/SubscriberError.js @@ -6,7 +6,7 @@ const setTimeoutUnref = require('../utils/setTimeoutUnref'); module.exports = function SubscriptionRecovery(broker, vhost) { this.handle = function (session, message, err, recoveryOptions, next) { - debug('Handling subscriber error for message: %s', message.properties.messageId); + debug('Handling subscriber error for message: %s with error: %s', message.properties.messageId, err.message); async.eachSeries( [].concat(recoveryOptions || []).concat({ strategy: 'fallback-nack' }), @@ -86,7 +86,7 @@ module.exports = function SubscriptionRecovery(broker, vhost) { if (strategyConfig.immediateNack) { const xDeathRecords = message.properties.headers['x-death'] || []; - const xDeath = xDeathRecords.find(({ queue, reason }) => queue === originalQueue && reason === 'rejected') || { count: 0 }; + const xDeath = xDeathRecords.find(({ queue, reason }) => queue === originalQueue && reason === 'rejected') || { count: 0, queue: originalQueue }; _.set(publishOptions, ['headers', 'rascal', 'recovery', originalQueue], { immediateNack: true, xDeath }); } diff --git a/test/subscriptions.tests.js b/test/subscriptions.tests.js index 9a01388..ff46f08 100644 --- a/test/subscriptions.tests.js +++ b/test/subscriptions.tests.js @@ -1739,7 +1739,7 @@ describe('Subscriptions', () => { count++; if (count <= 2) { assert.ok(message); - ackOrNack(new Error('immediate nack'), { + ackOrNack(new Error(`immediate nack: ${count}`), { strategy: 'republish', immediateNack: true, });