Class: Jackhammer::Queue
- Inherits:
-
Object
- Object
- Jackhammer::Queue
- Defined in:
- lib/jackhammer/queue.rb
Instance Attribute Summary collapse
-
#handler_object ⇒ Object
readonly
Returns the value of attribute handler_object.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Instance Method Summary collapse
-
#initialize(topic:, queue:, handler:, routing_key:) ⇒ Queue
constructor
A new instance of Queue.
- #subscribe ⇒ Object
Constructor Details
#initialize(topic:, queue:, handler:, routing_key:) ⇒ Queue
Returns a new instance of Queue.
5 6 7 8 9 10 |
# File 'lib/jackhammer/queue.rb', line 5 def initialize(topic:, queue:, handler:, routing_key:) @topic = topic @queue = queue @queue.bind @topic, routing_key: routing_key @handler_object = handler end |
Instance Attribute Details
#handler_object ⇒ Object (readonly)
Returns the value of attribute handler_object.
3 4 5 |
# File 'lib/jackhammer/queue.rb', line 3 def handler_object @handler_object end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
3 4 5 |
# File 'lib/jackhammer/queue.rb', line 3 def queue @queue end |
Instance Method Details
#subscribe ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/jackhammer/queue.rb', line 12 def subscribe queue.subscribe do |delivery_info, properties, content| Log.info { [delivery_info.inspect, properties.inspect].join(' || ') } Log.debug { content } Jackhammer.server_middleware.call( handler: handler_object, delivery_info: delivery_info, properties: properties, content: content ) do |**args| args.fetch(:handler).call args.fetch(:content) end rescue StandardError => e Log.error e Jackhammer.configuration.exception_adapter.call e end end |