Class: Basquiat::Adapters::RabbitMq::DeadLettering

Inherits:
BaseStrategy
  • Object
show all
Defined in:
lib/basquiat/adapters/rabbitmq/requeue_strategies/dead_lettering.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseStrategy

#ack, #nack, #requeue

Constructor Details

#initialize(session) ⇒ DeadLettering

Returns a new instance of DeadLettering.



28
29
30
31
# File 'lib/basquiat/adapters/rabbitmq/requeue_strategies/dead_lettering.rb', line 28

def initialize(session)
  super
  setup_dead_lettering
end

Class Attribute Details

.optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/basquiat/adapters/rabbitmq/requeue_strategies/dead_lettering.rb', line 8

def options
  @options
end

Class Method Details

.session_optionsObject



23
24
25
# File 'lib/basquiat/adapters/rabbitmq/requeue_strategies/dead_lettering.rb', line 23

def session_options
  options.fetch :session
end

.setup(opts) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/basquiat/adapters/rabbitmq/requeue_strategies/dead_lettering.rb', line 10

def setup(opts)
  @options = {
    session: {
      queue: {
        options: {
          'x-dead-letter-exchange' => opts.fetch(:exchange, 'basquiat.dlx')
        }
      }
    },
    dlx:     { ttl: opts.fetch(:ttl, 1_000) }
  }
end

Instance Method Details

#run(message) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/basquiat/adapters/rabbitmq/requeue_strategies/dead_lettering.rb', line 33

def run(message)
  catch :skip_processing do
    check_incoming_messages(message.props.headers)
    yield
  end
  public_send(message.action, message)
end