Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved recoverability and logging #373

Merged
merged 11 commits into from
Aug 31, 2024
Merged

Conversation

dgafka
Copy link
Member

@dgafka dgafka commented Aug 31, 2024

Description

This improves recoverabiility for asynchronous scenarios and logging (to provide more info what's happening with Message when it fails)

$retryStrategy->runCallbackWithRetries(function () use ($message) {
try {
$this->insertHandledMessage($message->getPayload(), $message->getHeaders()->headers());
}catch (\Exception $exception) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

retrying on failure to store in dead letter. If we will manage to store it, there is no need to nack the message in the channel

$exception
);
} catch (Exception) {
$connection->close();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we failed on rollback, it most likely means the connection is already dead, therefore we can close right away.

}
if ($amqpAcknowledgementCallback->isAutoAck()) {
$retryStrategy->runCallbackWithRetries(function () use ($message, $methodInvocation, $logger, $messageChannelName, $amqpAcknowledgementCallback) {
$amqpAcknowledgementCallback->accept();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can try to ack with retries, under the hood connection will disconnected when acking fails.
This will help in scenarios like: dbal, redis, sqs channels, however won't help in recovering from AMQP (as same connection is needed for acking).
In case of AMQP, message will be requeued and rehandled again.

@dgafka dgafka merged commit bc5780d into main Aug 31, 2024
59 checks passed
@dgafka dgafka deleted the improved-recoverability-and-logging branch August 31, 2024 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant