Support the ongoing development of Laravel.io →
posted 9 years ago
Queues
Last updated 2 years ago.
0

Lets say we are using redis queues

In queue.php we need to define queues for example :


       'default' => 'redis-low',
       
       'connections' => [

          'redis-high' => [
            'driver' => 'redis',
            'queue'  => 'redis-high',
          ],

          'redis-medium' => [
            'driver' => 'redis',
            'queue'  => 'redis-medium',
          ],

          'redis-low' => [
            'driver' => 'redis',
            'queue'  => 'redis-low',
          ],
       ],
      
    'failed' => [
        'database' => 'mysql', 'table' => 'failed_jobs',
    ]

Now whenever you push a queue as in :

Queue::push("-----");

It will be automatically pushed to the default queue you have chosen in the queue.php file In the configuration above "redis-low" is the default queue

If you want to push to a particular queue you can use

Queue::pushOn('queue name', Queue job);

For example:

  Queue::pushOn('redis-high', new SendEmail($message));

  Queue::pushOn('redis-low', '\App\Services\Queues\QueueService', $dataArray);

We tell the queue execution order to the server:

we can do this by using the "--queue" option

For example

php artisan queue:listen --queue=redis-high,redis-medium,redis-low

Thats all Cheers enjoy

Last updated 9 years ago.
0

mrigank237 said:

Lets say we are using redis queues

In queue.php we need to define queues for example :


      'default' => 'redis-low',
      
      'connections' => [

         'redis-high' => [
           'driver' => 'redis',
           'queue'  => 'redis-high',
         ],

         'redis-medium' => [
           'driver' => 'redis',
           'queue'  => 'redis-medium',
         ],

         'redis-low' => [
           'driver' => 'redis',
           'queue'  => 'redis-low',
         ],
      ],
     
   'failed' => [
       'database' => 'mysql', 'table' => 'failed_jobs',
   ]

Now whenever you push a queue as in :

Queue::push("-----");

It will be automatically pushed to the default queue you have chosen in the queue.php file In the configuration above "redis-low" is the default queue

If you want to push to a particular queue you can use

Queue::pushOn('queue name', Queue job);

For example:

 Queue::pushOn('redis-high', new SendEmail($message));

 Queue::pushOn('redis-low', '\App\Services\Queues\QueueService', $dataArray);

We tell the queue execution order to the server:

we can do this by using the "--queue" option

For example

php artisan queue:listen --queue=redis-high,redis-medium,redis-low

Thats all Cheers enjoy

Thanks for your reply. But i was looking for something through which i can priorities my job rather than the queues. Anyways.Can you explain me how the jobs in each of these queue will be executed. Let say redis-high have 5 jobs in it. and redis-medium have 3 jobs, redis-low has 2 jobs. So when the execution starts will it will finish the redis-high 5 jobs and then redis-medium 3 jobs and so on ...or is it something different.How exactly it is?

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.