Skip to content

Commit

Permalink
configure sneakers to use maxretry handler
Browse files Browse the repository at this point in the history
  • Loading branch information
eliotjordan committed Oct 14, 2016
1 parent 42bf928 commit 6a65b5f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/workers/plum_event_handler.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
class PlumEventHandler
include Sneakers::Worker
from_queue :pomegranate
from_queue :pomegranate,
WORKER_OPTIONS.merge(
arguments: { 'x-dead-letter-exchange': 'pomegranate-retry' }
)

def work(msg)
msg = JSON.parse(msg)
Expand Down
14 changes: 13 additions & 1 deletion config/initializers/sneakers.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
require 'sneakers'
require 'sneakers/handlers/maxretry'
require_relative 'pom_config'
Sneakers.configure(
amqp: Pomegranate.config["events"]["server"],
exchange: Pomegranate.config["events"]["exchange"],
exchange_type: :fanout
exchange_type: :fanout,
handler: Sneakers::Handlers::Maxretry
)
Sneakers.logger.level = Logger::INFO

WORKER_OPTIONS = {
ack: true,
threads: 10,
prefetch: 10,
timeout_job_after: 60,
heartbeat: 5,
amqp_heartbeat: 10,
retry_timeout: 60 * 1000 # 60 seconds
}.freeze

0 comments on commit 6a65b5f

Please sign in to comment.