Saturday, January 6, 2024

Laravel 10.39 is Released with Load-balancing Mailer, Maximum Tries Queue etc


This week, the Laravel team released version 10.39 with a round-robin mailer, dynamic maximum attempts for queue jobs, and more. Here's a brief overview of the new features introduced in Laravel v10.39 this week:

Round-robin Mailer:

Ahmed Shamim contributed to a round-robin mailer transport driver that distributes delivery workloads across multiple transports. In simple terms, this driver extends the failover transport driver by changing the logic for selecting the next transport. The failover driver helps achieve high availability, while round-robin helps achieve load balancing.

To use this feature, update your application configuration in the config/mail.php file in your Laravel application:

'roundrobin' => [
    'transport' => 'roundrobin',
    'mailers' => [
        'ses',
        'postmark',
    ],
],

This feature is documented in the official Mail documentation on round-robin configuration. You can learn more in Symfony Mailer's load balancing documentation and Pull Request #49435.

Dynamic Maximum Attempts for Queue Jobs:

@Di contributed the ability to dynamically determine maxTries for queue jobs, similar to backoff(). Previously, you could set a dynamic value through the $tries property (which still takes precedence), but now you can define a method on your job:

class TestJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    // If the property is still defined, it precedes over the tries() method,
    // providing the same behavior as the backoff definition
    public $tries = 3;

    public function tries(): int
    {
        return config('test_job.retries'); // Example: Get the number of tries from config
    }
}

Release Notes:

You can find the complete list of new features and updates below, and the differences between versions 10.38.0 and 10.39.0 on GitHub. The release notes below are directly from the changelog:

v10.39.0

0 comments:

Post a Comment