You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the main queue is empty after 20 seconds, the client then listens on the slow queue for 20 seconds. While listening on the slow queue, any item arriving in the main queue will have to wait till the slow queue listen is over, and the next main queue listen, to be processed.
Timeline:
Listener starts to wait on main queue
Nothing to process
Listener stops listening on main queue after 20 seconds
Listener starts to wait on slow queue
Nothing to process
After 1 second an item is added to the main queue
Listener stops listening on the slow queue after a further 19 seconds
Listener starts to wait on main queue
Item in main queue is immediately received and processed, 19 seconds after it was published.
Code to show in action:
topic = :slow_queue_delay_test
client = Propono::Client.new
Thread.new do
client.listen(topic) do |payload|
puts "Message processed after #{Time.now.to_i - payload[:time]} seconds"
end
end
# One second longer than the long-poll time.
sleep 21
PublishProponoMessage.(topic, { time: Time.now.to_i })
# Keep the main thread alive.
sleep 30
Suggested Solution:
Give the main queue a 20 second head-start, before listening on both queues. Reset this head-start after ever job processed.
Listen to the main queue for 20 seconds.
Listen to the main AND slow queues indefinitely.
If a job turns up in one queue or the other, process it, go back to (1).
The text was updated successfully, but these errors were encountered:
If the main queue is empty after 20 seconds, the client then listens on the slow queue for 20 seconds. While listening on the slow queue, any item arriving in the main queue will have to wait till the slow queue listen is over, and the next main queue listen, to be processed.
Timeline:
Code to show in action:
Suggested Solution:
Give the main queue a 20 second head-start, before listening on both queues. Reset this head-start after ever job processed.
The text was updated successfully, but these errors were encountered: