0

I want to guarantee that a task is not in a task queue more then once, so I generate a unique name based on it's payload. But, that task name is reserved for up to 7 days, which is not what I want; I only want it reserved for the duration the task is queued; it could be immediately re-queued.

Once a Task with name N is written, any subsequent attempts to insert a Task named N will fail. Eventually (at least seven days after the task successfully executes), the task will be deleted and the name N can be reused.

Is there a way to check if the named task is already in the queue then add it if it's not? Or a totally different approach?

1 Answer 1

1

You need to take a different approach - for example, including the time interval over which you want the name to be unique in the task name, or including a 'job number' that you increment for each new task.

Sign up to request clarification or add additional context in comments.

5 Comments

Nick has an example of computing a task name which includes the time interval here (though in Python the concept will be straightforward to implement in Java as well).
I get the solution as it applies to my situation, but I don't see how using tasks for updates at periodic intervals is different from using a cron job.
I'm jealous that in python you're allowed to use dashes in task names.
@antony Because you get to schedule the jobs at runtime, rather than having to pre-specify it in a configuration file at design time. There's also no need to schedule jobs for intervals that you know will have no work that requires doing.
gotchu. you should include the link to the post in your answer. thanks again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.