Sha256: 3b985bee8ac0632bc494b9c4f883a94384ec6c0a78b2b5370e9892efda58e98e

Contents?: true

Size: 830 Bytes

Versions: 6

Compression:

Stored size: 830 Bytes

Contents

require "baton"
require "amqp"
require "json"
require "eventmachine"

module Baton
  class <%= config[:constant_array].last %>Monitor
    include Baton::Logging

    def self.run
      monitor = <%= config[:constant_array].last %>Monitor.new
      monitor.run
    end

    def run
      logger.info "Starting <%= config[:name] %> monitor v#{Baton::VERSION}"
      EM.run do
        connection = AMQP.connect(Baton.configuration.connection_opts)

        channel  = AMQP::Channel.new(connection)
        queue    = channel.queue("<%= config[:name] %>-monitor")
        exchange_out = channel.direct(Baton.configuration.exchange_out)

        queue.bind(exchange_out).subscribe do |payload|
          logger.info "Message read: #{payload}"
          #TODO Do something with the payload here
        end
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
baton-0.4.4 lib/baton/templates/gem/lib/baton/gem/gem-monitor.rb.tt
baton-0.4.3 lib/baton/templates/gem/lib/baton/gem/gem-monitor.rb.tt
baton-0.4.2 lib/baton/templates/gem/lib/baton/gem/gem-monitor.rb.tt
baton-0.4.1 lib/baton/templates/gem/lib/baton/gem/gem-monitor.rb.tt
baton-0.3.7 lib/baton/templates/gem/lib/baton/gem/gem-monitor.rb.tt
baton-0.3.6 lib/baton/templates/gem/lib/baton/gem/gem-monitor.rb.tt