I am using a Spring Boot application with multiple instances and leveraging the RDelayedQueue from the Redisson library. I noticed that the library uses long timeout = System.currentTimeMillis() + delayInMs
as the score for elements in a sorted set.
Here’s my concern, two tasks are offered to the delayed queue at the same time, resulting in the same timeout score.
- Instance 1: delayed.offer(“A”, delayTime, TimeUnit.MINUTES)
- Instance 2: delayed.offer(“B”, delayTime, TimeUnit.MINUTES)
Given that Redis is single-threaded and processes commands sequentially, my questions are:
- How does Redisson handle the insertion and retrieval of elements with the same score in this scenario?
- If the insertion of task “B” is processed first, will task “A” still be polled first because of its lexicographical order?
- Does this behavior deviate from the traditional FIFO queue concept, and if so, how does RDelayedQueue ensure consistent polling order?
I would appreciate insights on how Redis manages this and any potential implications for using RDelayedQueue in a distributed environment with multiple instances.