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
162 163 164 165 166 167 168 169 |
# File 'lib/hot_bunnies/queue.rb', line 162 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
156 157 158 159 160 |
# File 'lib/hot_bunnies/queue.rb', line 156 def (&block) raise ArgumentError, 'Message listener already registered for this subscriber' if @subscriber @subscriber = block start end |
#start ⇒ Object
152 153 154 |
# File 'lib/hot_bunnies/queue.rb', line 152 def start # to be implemented by the host class end |