Redis-based customized delay time
Redis based delay queue
Flowchart
Redis ZSet
Delay queue: A list of ordered queues which store all delayed/reserved jobs (only stores job Id)
Timer
Scan delay bucket and put expired jobs into ready queue
Redis List
Ready queue: A list of ordered queues which store jobs in Ready state.
Topic: The same category of job collections
Dispatcher
It will poll the delay queue and move items to the corresponding topic within ready queues if the tasks are ready.
Worker: Workers use BLPOP on the ready queue and process the message. Once done, the response could be put in a response queue and send to consumer.
Job pool: Redis HashTable
JobPool: Store all metadata about jobs
Stores as key value pairs. Key is job id and value is job struct.
Job struct contains the following:
topic: job category. Needed because each category will has its own callback function.
id: job unique identifier
delayTime: time to delay before executing the task
ttr: timeout duration for this job to be executed
body: job content
callback: http url for calling a specific function
References
Last updated