Webador / SlmQueue

Laminas / Mezzio module that integrates with various queue management systems.
Other
137 stars 56 forks source link

Unique jobs in queue #158

Closed malinink closed 9 years ago

malinink commented 9 years ago

Hi, is there any way to check whether job is already in the queue? I need to add new job in the list, but i dont want to iterate over all of them to be shure that it is not exists. Unique key on fields(queue, data) will help, but I think it will crush SlmQueue.

Thank you!

basz commented 9 years ago

There is no supported manner in which to check if a particular Job and a specific payload is already on the queue.

Your suggestion to make the queue / data unique will (afaik) only work in the Doctrine adapter, but should work i'm guessing. You would need to catch exceptions and make sure processed jobs aren't removed from the db. You would be forcing all queue's to behave this way, which might not be what you want.

But to be honest, I believe housekeeping is a responsibility of the developer because it depends on your requirements too much. Keep track of each Job and relevant payload data you push onto a queue and search through that information before adding an new one... Note that after a push a Job will have been given a unique $job->getId()

Hope this helps

malinink commented 9 years ago

I hope that I miss something and that functional already exists.

So, I'll try to make world better.

Thank you for detailed answer!