module Asynk::Consumer
Public Class Methods
included(base)
click to toggle source
# File lib/asynk/consumer.rb, line 4 def self.included(base) base.extend(ClassMethods) base.include ActiveSupport::Rescuable Asynk.register_consumer(base) end
new(channel, delivery_info, &block)
click to toggle source
# File lib/asynk/consumer.rb, line 10 def initialize(channel, delivery_info, &block) @channel = channel @delivery_info = delivery_info @callback_block = block end
Public Instance Methods
ack!()
click to toggle source
# File lib/asynk/consumer.rb, line 16 def ack! @channel.ack(@delivery_info.delivery_tag) end
invoke_processing(message)
click to toggle source
# File lib/asynk/consumer.rb, line 36 def invoke_processing(message) method_for_exec = (self.class.route_ending_as_action? && message.routing_key) ? self.class.action_name_from_routing_key(message.routing_key) : :process begin public_send(method_for_exec, message) rescue Exception => ex raise(ex) unless rescue_with_handler(ex) end end
logger()
click to toggle source
# File lib/asynk/consumer.rb, line 28 def logger Asynk.logger end
reject!()
click to toggle source
# File lib/asynk/consumer.rb, line 20 def reject! @channel.reject(@delivery_info.delivery_tag) end
requeue!()
click to toggle source
# File lib/asynk/consumer.rb, line 24 def requeue! @channel.reject(@delivery_info.delivery_tag, true) end
respond(result)
click to toggle source
# File lib/asynk/consumer.rb, line 32 def respond(result) @callback_block.call(result) end