Module: DaemonObjects::AmqpSupport
- Defined in:
- lib/daemon_objects/amqp/runner.rb
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#prefetch ⇒ Object
Returns the value of attribute prefetch.
-
#queue ⇒ Object
Returns the value of attribute queue.
-
#worker_class ⇒ Object
Returns the value of attribute worker_class.
Instance Method Summary collapse
Instance Attribute Details
#endpoint ⇒ Object
Returns the value of attribute endpoint.
2 3 4 |
# File 'lib/daemon_objects/amqp/runner.rb', line 2 def endpoint @endpoint end |
#prefetch ⇒ Object
Returns the value of attribute prefetch.
2 3 4 |
# File 'lib/daemon_objects/amqp/runner.rb', line 2 def prefetch @prefetch end |
#queue ⇒ Object
Returns the value of attribute queue.
2 3 4 |
# File 'lib/daemon_objects/amqp/runner.rb', line 2 def queue @queue end |
#worker_class ⇒ Object
Returns the value of attribute worker_class.
2 3 4 |
# File 'lib/daemon_objects/amqp/runner.rb', line 2 def worker_class @worker_class end |
Instance Method Details
#arguments ⇒ Object
4 5 6 |
# File 'lib/daemon_objects/amqp/runner.rb', line 4 def arguments @arguments ||= {} end |
#run ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/daemon_objects/amqp/runner.rb', line 8 def run logger.info "Preparing to start the AMQP watcher." AMQP.start(endpoint) do |connection, open_ok| logger.info "Starting up the AMQP watcher." channel = AMQP::Channel.new(connection) channel.prefetch(1) if prefetch worker = worker_class.new( channel, get_consumer, { :queue_name => queue, :logger => logger, :arguments => arguments }) worker.start logger.info "AMQP worker started" Signal.trap("INT") do logger.info "Received signal 'INT'. Exiting process" connection.close { EventMachine.stop } end end end |