Module: HireFire::Macro::Deprecated::Bunny
- Included in:
- Bunny
- Defined in:
- lib/hirefire/macro/deprecated/bunny.rb
Overview
Provides backward compatibility with the deprecated Bunny macro. For new implementations, refer to Bunny.
Instance Method Summary collapse
-
#queue(*queues) ⇒ Integer
Retrieves the total number of jobs in the specified queue(s).
Instance Method Details
#queue(*queues) ⇒ Integer
Retrieves the total number of jobs in the specified queue(s).
This method allows querying multiple queues and supports both existing and new RabbitMQ connections. By default, queues are considered durable unless specified otherwise.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/hirefire/macro/deprecated/bunny.rb', line 31 def queue(*queues) require "bunny" queues.flatten! = queues.last.is_a?(Hash) ? queues.pop : {} [:durable] = true if [:durable].nil? if [:connection] connection = [:connection] channel = nil begin channel = connection.create_channel Private.(channel, queues, ) ensure channel&.close end elsif [:amqp_url] connection = ::Bunny.new([:amqp_url]) begin connection.start channel = connection.create_channel Private.(channel, queues, ) ensure channel&.close connection.close end else raise ArgumentError, "Must pass either :connection => rabbitmq_connection or :amqp_url => url." \ "For example: HireFire::Macro::Bunny.queue(\"queue1\", connection: rabbitmq_connection)" end end |