Sha256: 25ab647ae55e81e97f5c4b2d3e71360a822975fbc196b42a8ea04484ad7e19a5

Contents?: true

Size: 811 Bytes

Versions: 10

Compression:

Stored size: 811 Bytes

Contents

require "baton"
require "amqp"
require "json"
require "eventmachine"
require "baton/channel"

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

        baton_channel = Baton::Channel.new
        queue         = baton_channel.channel.queue("<%= config[:name] %>-monitor")
        exchange_out  = baton_channel.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

10 entries across 10 versions & 1 rubygems

Version Path
baton-0.7.0 lib/baton/templates/gem/lib/baton/gem/gem-monitor.rb.tt
baton-0.6.0 lib/baton/templates/gem/lib/baton/gem/gem-monitor.rb.tt
baton-0.5.6 lib/baton/templates/gem/lib/baton/gem/gem-monitor.rb.tt
baton-0.5.5 lib/baton/templates/gem/lib/baton/gem/gem-monitor.rb.tt
baton-0.5.4 lib/baton/templates/gem/lib/baton/gem/gem-monitor.rb.tt
baton-0.5.2 lib/baton/templates/gem/lib/baton/gem/gem-monitor.rb.tt
baton-0.4.10 lib/baton/templates/gem/lib/baton/gem/gem-monitor.rb.tt
baton-0.4.9 lib/baton/templates/gem/lib/baton/gem/gem-monitor.rb.tt
baton-0.4.8 lib/baton/templates/gem/lib/baton/gem/gem-monitor.rb.tt
baton-0.4.5 lib/baton/templates/gem/lib/baton/gem/gem-monitor.rb.tt