Job hash to prevent from enqueuing the same job twice

queues
Tags: #<Tag:0x00007f499ec3bc18>

#1

I looked at the docs and searched the Discourse but could not find anything about how the same job is being identified or this feature does not exist in Hangfire.
If this feature exists I recomment guys from Hangfire to add it to the documentation. Thanks.

Some example:
User changes dropdown state of the order to “Approved” and the app adds a new background task to the queue to notify the client with delay (eg. 5 min.). The task looks like this: Check if the order still in state Approved, if Yes then notify the client, if Not then don’t do anything. So the task won’t send notification if in less then 5 min user desided to switch the order state back to Processing. But a bit later user decided to switch the order status back to “Approved”, so a new background task created. Having delay 5 min now there are two same background tasks in the queue.

I would like Hangfire to look at the pending queue by some hash (which contains order_id and state approved) and do not add the background job to the queue. So it could be some hash of the job I can pass to Hangfire and tell that if there is already pending task with the same hash then don’t add that task to the queue.

Thanks for any help.