'Correct Implementation of Publisher Confirms - PHP AMQP
I have implemented publisher confirms but have a few questions regarding the right implementation. The current implementation is as follows.
$channel->set_ack_handler(
function (AMQPMessage $message) {
echo 'Message acked with content ' . $message->body . PHP_EOL;
}
);
$channel->confirm_select();
$channel->basic_publish($msg, $exchange);
$channel->wait_for_pending_acks(5);
// LOGIC IF THERE IS NO ACK WITHIN 5 SECONDS
// ASSUMING THAT THE EXECUTION WILL COME HERE AFTER 5 SECONDS
If the ACK is taking more than 5S, the execution is not going after $channel->wait_for_pending_acks(5). It is throwing an exception instead.
Exception: The connection timed out after 5 sec while awaiting incoming data
Is it like the package throws an exception always after waiting for $timeout (5 seconds in our case)? Or, is the exception happening due to something else? Does it make sense if I do like below?
try {
$channel->wait_for_pending_acks(5);
} catch (\Exception $e) {
// LOGIC IF THERE IS NO ACK WITHIN 5 SECONDS, REPUBLISH
}
Thanks for the help!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
