schmittjoh / JMSJobQueueBundle

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

There is no way to add argument(s) to Job instance on createCronJob when scheduling jobs #183

Closed olotintemitope closed 6 years ago

olotintemitope commented 6 years ago

Hi,

The bundle is indeed very useful. I have 2 use cases

  1. I will like to add arguments to the Job Instance when creating the cronjob from the command after implementing CronCommand.
public function createCronJob(\DateTime $lastRunAt)
{
        return new Job('business:invoice-reminder');
}

I will like to do this $job = new Job('business:invoice-reminder', [$invoiceReminder->getId()]);

  1. secondly, the
public function shouldBeScheduled(\DateTime $lastRunAt)
{
       return time() - $lastRunAt->getTimestamp() >= 180; // Executed at most every minute.
}

should allow for dynamic time rather than hardcoding a generic time for the scheduler to run at intervals.

I'm looking forward to a quick response. Thanks

schmittjoh commented 6 years ago

I think you can already do what you need. But you probably need some sort of schedule command that runs every day/hour and triggers reminder jobs.