Skip to content

Commit

Permalink
bug #53525 [Messenger] [AMQP] Throw exception on nack callback (kvr…
Browse files Browse the repository at this point in the history
…ushifa)

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 #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
-------

6ed35b6fe4 [Messenger] [AMQP] Throw exception on `nack` callback
  • Loading branch information
nicolas-grekas committed Jan 23, 2024
2 parents b8cf294 + b89670f commit f5ffb4c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Transport/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Symfony\Component\Messenger\Exception\InvalidArgumentException;
use Symfony\Component\Messenger\Exception\LogicException;
use Symfony\Component\Messenger\Exception\TransportException;

/**
* An AMQP connection.
Expand Down Expand Up @@ -516,8 +517,8 @@ public function channel(): \AMQPChannel
static function (): bool {
return false;
},
static function (): bool {
return false;
static function () {
throw new TransportException('Message publication failed due to a negative acknowledgment (nack) from the broker.');
}
);
}
Expand Down

0 comments on commit f5ffb4c

Please sign in to comment.