Module: Travis::Amqp

Defined in:
lib/travis/amqp.rb

Class Method Summary collapse

Class Method Details

.publish(queue, payload) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/travis/amqp.rb', line 16

def publish(queue, payload)
  body = MultiJson.encode(payload)

   = {
    :routing_key => queue,
    :persistent  => true,
    :durable     => true,
    :auto_delete => false
  }

  exchange.publish(body, )
end

.setup_connectionObject



6
7
8
9
10
11
12
13
14
# File 'lib/travis/amqp.rb', line 6

def setup_connection
  require 'amqp/utilities/event_loop_helper'
  AMQP::Utilities::EventLoopHelper.run

  AMQP.start(Travis.config.amqp) do |connection|
    Rails.logger.info 'Connected to AMQP broker'
    AMQP.channel = AMQP::Channel.new(connection)
  end
end