schmittjoh / JMSJobQueueBundle

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

Job ID #46

Closed kingcrunch closed 10 years ago

kingcrunch commented 10 years ago

Feature suggestion: Job IDs/Keys

Arbitrary strings, that may be reused later, but must be unique in the queue.

$job = new Job('a');
$job->setId('Update user 123');
$em->persist($job);
$em->flush();
$job = new Job('a');
$job->setId('Update user 123');
$em->persist($job);
$em->flush();
// Should fail, or silently dropped, because job with that ID is already enqueued
$job = new Job('a');
$job->setId('Update user 123');
$em->persist($job);
$em->flush();

// Wait a looong time

$job = new Job('a');
$job->setId('Update user 123');
$em->persist($job);
$em->flush();
// May succeed, when the previous job was processed

null means "current behaviour".

To be honest: Handling this on the entity manager directly makes me feel a little bit uncomfortable. Is theres a reason, why there is no layer in between (like Queue with $queue->enqueue($job);)?