Framework: Dynamic Queues not working

Created on 1 Nov 2018  路  6Comments  路  Source: laravel/framework

  • Laravel Version: 5.5
  • PHP Version: 7.1
  • Database Driver & Version: Redis

Description:

@taylorotwell I am using Laravel queues to process jobs in a connection , since i have a dynamic queue name , I cannot specify queue name when using queue:work command, since I tried search a solution for it in laravel and other forums , It turned out to be a dead end

Steps To Reproduce:

Create a dynamic queue name while scheduling queues and check it in horizon dashboard

All 6 comments

Why are you using dynamic queue names in the first place? Just use dedicated queues?

@laurencei we have a requirement to use multiple queues. and need to process it simultaneously, since we have lot of queue connections already for many things Notifications, and few Variety of jobs in which the jobs in the queue has equal priority. in scaled environment we have time lags for processing bunch of jobs in one or predefined queues

@taylorotwell Sorry to mention again here if there is option to process queue on dynamic names it would be help full and also no option to set queue connection on Broadcast class or On event Class

Have you considered building a custom queue that would fetch from multiple queues? As an example, it could involve extending the DatabaseQueue and just remove the WHERE queue = $queue part of the logic that selects a new job. Or change it into WHERE queue LIKE 'my-queues-%'

@sisve Thanks, But may i know At which Class that handles RedisQueue, If this feature is added it would be good

I do not know the redis commands well enough to tell you how to implement this, but the current system is based on RedisQueue::retrieveNextJob which uses a lua-script found in LuaScripts::pop.

At a first glance I do not see anyway to rewrite the script to lpop from any of the given queues. It looks like you will always have to poll redis for one queue at a time, so your best bet (in my naive eyes) is to have a list of all queues to fetch from, and shuffle it randomly. This way you'll still take the first available job you find, but the order you process the queues will differ everytime you call retrieveNextJob.

@laurencei The same problem! I need to handle batch of tasks, for example, 1 000 pieces. And I need to be able to stop the batch of tasks and see the progress of the handling. This is most conveniently done through a dynamic queue name. One unique queue name for each batch of tasks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

YannPl picture YannPl  路  3Comments

kerbylav picture kerbylav  路  3Comments

lzp819739483 picture lzp819739483  路  3Comments

Fuzzyma picture Fuzzyma  路  3Comments

RomainSauvaire picture RomainSauvaire  路  3Comments