Skip to content

Commit 52b0fed

Browse files
bug symfony#53525 [Messenger] [AMQP] Throw exception on nack callback (kvrushifa)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [Messenger] [AMQP] Throw exception on `nack` callback | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix symfony#53229 | License | MIT If the channel is in confirm mode, it is currently not possible to determine if a message has been nack'ed. By throwing an exception within the confirm callback, it is at least possible to react to it. Return false is not needed to end the wait loop, [since the amqp ext checks for exceptions](https://github.com/php-amqp/php-amqp/blob/e58ac221e317c840ee06f7731e0dc76c7d6a431a/amqp_methods_handling.c#L249). Commits ------- 6ed35b6 [Messenger] [AMQP] Throw exception on `nack` callback
2 parents 6d702ee + 6ed35b6 commit 52b0fed

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Messenger\Exception\InvalidArgumentException;
1515
use Symfony\Component\Messenger\Exception\LogicException;
16+
use Symfony\Component\Messenger\Exception\TransportException;
1617

1718
/**
1819
* An AMQP connection.
@@ -516,8 +517,8 @@ public function channel(): \AMQPChannel
516517
static function (): bool {
517518
return false;
518519
},
519-
static function (): bool {
520-
return false;
520+
static function () {
521+
throw new TransportException('Message publication failed due to a negative acknowledgment (nack) from the broker.');
521522
}
522523
);
523524
}

0 commit comments

Comments
 (0)