Class: EstormMessageProcessor::Consumer
- Inherits:
-
Bunny::Consumer
- Object
- Bunny::Consumer
- EstormMessageProcessor::Consumer
- Defined in:
- lib/estorm-message-processor/consumer.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
- #cancelled? ⇒ Boolean
- #count ⇒ Object
- #handle_cancellation(_) ⇒ Object
- #increment ⇒ Object
-
#process_messages(delivery_info, metadata, body) ⇒ Object
process message.
-
#queue_statistics ⇒ Object
get the queue statistics and log it.
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
7 8 9 |
# File 'lib/estorm-message-processor/consumer.rb', line 7 def logger @logger end |
Instance Method Details
#cancelled? ⇒ Boolean
8 9 10 |
# File 'lib/estorm-message-processor/consumer.rb', line 8 def cancelled? @cancelled end |
#count ⇒ Object
11 12 13 14 |
# File 'lib/estorm-message-processor/consumer.rb', line 11 def count @mycount=0 if @mycount==nil @mycount end |
#handle_cancellation(_) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/estorm-message-processor/consumer.rb', line 19 def handle_cancellation(_) msg="consumer cancellation queue called" @logger.info msg @cancelled = true end |
#increment ⇒ Object
15 16 17 |
# File 'lib/estorm-message-processor/consumer.rb', line 15 def increment @mycount=self.count+1 end |
#process_messages(delivery_info, metadata, body) ⇒ Object
process message
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/estorm-message-processor/consumer.rb', line 26 def (delivery_info,,body) begin cmdhash=YAML.load(body) delegatestring="delegate_#{cmdhash['command']}" # create procedures named delegate_command accepting cmdhash msg = "-----> [gem estorm message processor: consumer] Received from App #{body} calling delegate #{delegatestring} count: #{self.count} " @logger.info msg self.send(delegatestring,cmdhash) # self.send(delegatestring,cmdhash) #load the promotion and process through data self.increment rescue Exception => e # add could not convert integer msg= "[gem estorm message processor] bunny exception #{e.} found #{e.inspect} #{e.backtrace}..." #THIS NEEDS WORK! @logger.info msg end end |
#queue_statistics ⇒ Object
get the queue statistics and log it.
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/estorm-message-processor/consumer.rb', line 44 def queue_statistics msg_count=0 begin msg_count =@queue. consumer_count =@queue.consumer_count msg = "queue status for queue [#{@queue.name}] message count: #{msg_count} consumers: #{consumer_count}" @logger.info msg if @logger!=nil rescue Exception => e msg = "exception in queue statistics #{e.inspect}" @logger.info msg if @logger!=nil end [msg_count, consumer_count] end |