Module: HotBunnies::Queue::Subscriber
- Included in:
- BlockingSubscriber
- Defined in:
- lib/hot_bunnies/queue.rb
Instance Method Summary collapse
- #handle_message(consumer_tag, envelope, properties, body_bytes) ⇒ Object
- #on_message(&block) ⇒ Object
- #start ⇒ Object
Instance Method Details
#handle_message(consumer_tag, envelope, properties, body_bytes) ⇒ Object
133 134 135 136 137 138 139 140 |
# File 'lib/hot_bunnies/queue.rb', line 133 def (consumer_tag, envelope, properties, body_bytes) body = String.from_java_bytes(body_bytes) case @subscriber.arity when 2 then @subscriber.call(Headers.new(@channel, consumer_tag, envelope, properties), body) when 1 then @subscriber.call(body) else raise ArgumentError, 'Consumer callback wants no arguments' end end |
#on_message(&block) ⇒ Object
127 128 129 130 131 |
# File 'lib/hot_bunnies/queue.rb', line 127 def (&block) raise ArgumentError, 'Message listener already registered for this subscriber' if @subscriber @subscriber = block start end |
#start ⇒ Object
123 124 125 |
# File 'lib/hot_bunnies/queue.rb', line 123 def start # to be implemented by the host class end |