问题
I am a little confused as to whether priorities work at the job or queue/tube level. The reason I ask is that I am using a beanstalkd integration module in Drupal. This module enables one to define queues/tubes and assign a priority value to each queue/tube created.
What I am trying to work out is the following. Let's say I have two queues/tubes in Beanstalkd (queue A and queue B). If items assigned to Queue A have a higher priority than items in Queue B, does that mean items in Queue B will only be processed when Queue A is empty?
回答1:
Priorities are per jobs, you can read more about this at: https://github.com/kr/beanstalkd/blob/master/doc/protocol.txt
Without job priorities, beanstalkd operates as a FIFO queue.
There are three hard facts to know about job priorities:
- Jobs with lower priority numbers are reserved before jobs with higher priority numbers.
- beanstalkd priorities are 32-bit unsigned integers (they range from 0 to 2^32 - 1).
- beanstalkd uses 2^31 as default job priority (beanstalkd.DEFAULT_PRIORITY) (the client may override this, I've seen defaults set to 1024).
Note also that within the same priority jobs are still handled in a FIFO manner. So if you have an agent that watches on multiple tubes, and when you get same priority jobs on those tubes they will get reserved in FIFO manner.
You can watch the tubes and jobs with https://github.com/ptrofimov/beanstalk_console
来源:https://stackoverflow.com/questions/23096625/do-priorities-work-across-queues-tubes-in-beanstalkd