require 'evrone/common/amqp' module Evrone::CI::Router::AMQP Base = Struct.new("Subscribing", :app) do include Evrone::CI::Router::Helper::Logger def consumer_name Thread.current[:consumer_name] end def consumer_id Thread.current[:consumer_id] end def consumer_tag consumer_id ? "#{consumer_name.split('::').last} #{consumer_id}" : consumer_name end end class Subscribing < Base def call(env) logger.tagged(consumer_tag) do logger.warn "subsribing #{env[:exchange].name}" rs = app.call env logger.warn "shutdown" rs end end end class Recieving < Base def call(env) logger.warn "payload recieved #{env[:payload].inspect[0...60]}..." rs = app.call env logger.warn "commit message" rs end end class Publishing < Base def call(env) app.call env end end end Evrone::Common::AMQP.configure do |c| c.subscribing do use Evrone::CI::Router::AMQP::Subscribing end c.recieving do use Evrone::CI::Router::AMQP::Recieving end c.publishing do use Evrone::CI::Router::AMQP::Publishing end c.content_type = 'application/x-protobuf' c.logger = nil end