gresrun / jesque

An implementation of Resque in Java.

Home Page:http://gresrun.github.io/jesque

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Removing an enqueued job by key

seglo opened this issue · comments

Hey,

I have a use case for the delay queue implementation of jesque. Delaying works great, but I also want the option to remove things from the queue. The call to removeDelayedEnqueue requires the queue name and the Job that includes the whole payload I originally queued. I would like to be able to remove something from the queue based on a key instead of the whole payload.

Am I missing something here? When I look at the implementation it looks like the whole value is serialized as the key & value when calling zadd.

To elaborate. Say I have a record of data I want to delay processing on.

class FooRecord
- id
- otherData

I want to call delayedEnqueue with the entire payload, but use the id as the key exclusively. When items are dequeued I want to get the entire payload.

If for some reason I need to remove a record from the queue I want to remove it by its id, because I may not know the other fields at the time (description). The signature for removeDelayedEnqueue requires the whole payload because everything is used for generating the key in redis.

Please advise.

When I dug deeper into the Jesque impl. and actual Redis commands I discovered that the Jesque behaviour is consistent. I worked around this by using Jedis directly. I add the key to a sorted set using time as score (just like Jesque), but in the same transaction I add a normal key/value pair to redis. On the consumer side I get all new messages from the sorted set, and then get/delete the value from redis.