Explain Delayed Queue



Similar Posts:


linkedin
github
slack

Name Example
Delayed queue blocking + priority queue
Providers of delayed queue feature Link: Amazon SQS Delay Queues, Link: Java DelayQueue

Q: What are the use cases of delayed queue?

  • Programming with eventual consistency model in distributed applications/systems.
  • Add a delay between two activities
My application needs to have an internal queue with each item
waiting at least one minute between each check for completion.

So instead of having to manage a "last-checked-time" on every
object, I just shove the object's ID into an SQS queue
messagewith a delay time of 60 seconds, and my main loop then
becomes a simple long-poll against the queue.
  • In Uber, if riders don’t pay within 7 days, send over the money to drivers directly.

Q: How delayed queue is implemented?

DelayQueue is a specialized PriorityQueue that orders elements based on their delay time. link

  • When delay hasn’t expired, the message in queue is can’t be taken.
  • The head of the queue is the element whose delay expired furthest in the past.


Share It, If You Like It.

Leave a Reply

Your email address will not be published. Required fields are marked *