Skip to content

Commit

Permalink
seperate queue for mqtt retries, with custom backoff schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
timcowlishaw committed May 6, 2024
1 parent 736ad61 commit 1760d33
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/jobs/retry_mqtt_message_job.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
class RetryMQTTMessageJob < ApplicationJob
queue_as :default
queue_as :mqtt_retry

sidekiq_retry_in do |count|
case count
when 0..10 # Every 30 seconds for the first 5 minutes
30.seconds
when 11..55 # Then every minute for an hour
1.minute
else
false # Fallback to default backoff after an hour,
# see https://github.com/sidekiq/sidekiq/issues/2338
end
end

def perform(topic, message)
result = MqttMessagesHandler.handle_topic(topic, message, false)
Expand Down
1 change: 1 addition & 0 deletions config/sidekiq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
:queues:
- default
- mailers
- mqtt_retry

production:
:concurrency: 25
Expand Down

0 comments on commit 1760d33

Please sign in to comment.