schmittjoh / JMSJobQueueBundle

Run and Schedule Symfony Console Commands as Background Jobs
http://jmsyst.com/bundles/JMSJobQueueBundle
335 stars 254 forks source link

Jobs are not running in priority order #144

Closed jdulude closed 8 years ago

jdulude commented 8 years ago

The const's inside the Job.php file that specify the priority of LOW, DEFAULT, and HIGH are in reverse order from the sorting within the JobRepository->findPendingJob method. See below...

Entity/Job.php

const PRIORITY_LOW = -5; const PRIORITY_DEFAULT = 0; const PRIORITY_HIGH = 5;

Entity/Repository/JobRepository.php -> findPendingJob method

->orderBy('j.priority', 'ASC')

schmittjoh commented 8 years ago

Did you run into any problems because this should be multiplied by -1 here: https://github.com/schmittjoh/JMSJobQueueBundle/blob/252f93dbc293905d05e19ed9a230246235a2b8f2/Entity/Job.php#L204

jdulude commented 8 years ago

Well what I ran into was noticing that my -5 jobs were running before the 0 or 5 priority jobs and when looking at the code it seemed like the sort should be DESC rather then ASC.

jdulude commented 8 years ago

Ah ok I see what you're saying now. I was expected the db to read the same as the code and was getting confused. Thanks for the explanation.