Skip to content

Commit

Permalink
Debug breaking tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cressie176 committed May 27, 2024
1 parent 1551510 commit 3d6ae09
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/amqp/Subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ function Subscription(broker, vhost, subscriptionConfig, counter) {
session._incrementUnacknowledgeMessageCount(message.fields.consumerTag);

decorateWithRoutingHeaders(message);
if (immediateNack(message)) return ackOrNack(session, message, true);
if (immediateNack(message)) return {
debug('Immediately nacking message: %s from queue: %s', message.properties.messageId, config.queue);
ackOrNack(session, message, true);
}

decorateWithRedeliveries(message, (err) => {
if (err) return handleRedeliveriesError(err, session, message);
Expand Down Expand Up @@ -210,8 +213,8 @@ function Subscription(broker, vhost, subscriptionConfig, counter) {
function immediateNack(message) {
const originalQueue = message.properties.headers.rascal.originalQueue;
const xDeathRecords = message.properties.headers['x-death'] || [];
const currentXDeath = xDeathRecords.find(({ queue, reason }) => queue === originalQueue && reason === 'rejected') || { count: 0 };
const previousXDeath = _.get(message, ['properties', 'headers', 'rascal', 'recovery', originalQueue, 'xDeath'], { count: 0 });
const currentXDeath = xDeathRecords.find(({ queue, reason }) => queue === originalQueue && reason === 'rejected') || { count: 0, queue: originalQueue };
const previousXDeath = _.get(message, ['properties', 'headers', 'rascal', 'recovery', originalQueue, 'xDeath'], { count: 0, queue: originalQueue });
const hasImmediateNackHeader = _.has(message, ['properties', 'headers', 'rascal', 'recovery', originalQueue, 'immediateNack']);
if (!hasImmediateNackHeader) return false;
debug('Message %s has been marked for immediate nack. Previous xDeath is %o. Current xDeath is %o.', message.properties.messageId, previousXDeath, currentXDeath);
Expand Down

0 comments on commit 3d6ae09

Please sign in to comment.