lib/baton/templates/gem/lib/baton/gem/gem-monitor.rb.tt in baton-0.4.4 vs lib/baton/templates/gem/lib/baton/gem/gem-monitor.rb.tt in baton-0.4.5
- old
+ new
@@ -1,9 +1,10 @@
require "baton"
require "amqp"
require "json"
require "eventmachine"
+require "baton/channel"
module Baton
class <%= config[:constant_array].last %>Monitor
include Baton::Logging
@@ -13,14 +14,13 @@
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)
+ 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