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

[spiral/queue] Add Retry Strategy Management to the Spiral Queue Component #911

Closed
butschster opened this issue Apr 3, 2023 · 0 comments · Fixed by #980
Closed

[spiral/queue] Add Retry Strategy Management to the Spiral Queue Component #911

butschster opened this issue Apr 3, 2023 · 0 comments · Fixed by #980
Assignees
Milestone

Comments

@butschster
Copy link
Member

The Spiral framework's queue component allows developers to push and consume queued tasks, but it currently does not have the ability to manage retry strategies for failed jobs. This can be problematic in cases where jobs fail due to transient errors or external dependencies, as retrying the job can increase the likelihood of a successful outcome.

Proposal

I propose that the Spiral queue component be updated to include retry strategy management using the queue.php configuration file. This would allow developers to define retry strategies for each connection in the queue, as well as a default retry strategy for all connections.

<?php

declare(strict_types=1);

return [
    'default' => env('QUEUE_CONNECTION', 'roadrunner'),
    'connections' => [
        'roadrunner' => [
            'driver' => 'roadrunner',
            'pipeline' => 'amqp',
            'retry_strategy' => new LinearRetryStrategy(maxRetries: 3, delayMilliseconds: 1000),
        ],
    ],

    'retry_strategy' => new MultiplierRetryStrategy(
        maxRetries: 3, 
        delayMilliseconds: 1000, 
        multiplier: 1.5, 
        maxDelayMilliseconds: 3000
    ),
    // ...
];

Benefits

Adding retry strategy management to the Spiral queue component would provide the following benefits:

  1. Improved reliability: By automatically retrying failed jobs according to a defined strategy, the framework would increase the likelihood of successful job execution.

  2. Flexibility: Developers could define different retry strategies for different connections, allowing them to optimize for specific use cases.

  3. Ease of use: The retry strategies could be defined in the queue.php configuration file, which is already used to configure other queue-related settings.

@butschster butschster added this to the 4.0 milestone Apr 3, 2023
@butschster butschster self-assigned this Apr 3, 2023
@msmakouz msmakouz linked a pull request Sep 5, 2023 that will close this issue
@butschster butschster modified the milestones: 4.0, 3.9 Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant