Module: Vx::Common::AMQP

Extended by:
AMQP
Included in:
AMQP
Defined in:
lib/vx/common/amqp_setup.rb

Instance Method Summary collapse

Instance Method Details

#setup(logger, options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/vx/common/amqp_setup.rb', line 10

def setup(logger, options = {})
  Vx::Common::AMQP.configure do |c|

    c.before_subscribe do |e|
      logger.warn "[#{e[:name]}] subsribing #{e[:exchange].name}"
    end

    c.after_subscribe do |e|
      logger.warn "[#{e[:name]}] shutdown"
    end

    c.before_recieve do |e|
      logger.warn "[#{e[:name]}] payload recieved #{e[:payload].inspect[0..60]}"
    end

    c.after_recieve do |e|
      logger.warn "[#{e[:name]}] commit message"
    end

    c.on_error do |e|
      Vx::Common::ErrorNotifier.notify(e)
    end

    c.content_type = 'application/x-protobuf'
    c.logger       = nil
    c.url          = options[:url]

  end
end