Sha256: 65610729c0b64e4d4967f8915bf0357a046a40a0e2be79fc094a15180643a4de

Contents?: true

Size: 863 Bytes

Versions: 4

Compression:

Stored size: 863 Bytes

Contents

module Jackhammer
  class Queue
    attr_reader :queue, :handler_object

    def initialize(topic:, queue:, handler:, routing_key:)
      @topic = topic
      @queue = queue
      @queue.bind @topic, routing_key: routing_key
      @handler_object = handler
    end

    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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jackhammer-1.5.1 lib/jackhammer/queue.rb
jackhammer-1.5.0 lib/jackhammer/queue.rb
jackhammer-1.5.0.rc lib/jackhammer/queue.rb
jackhammer-1.4.0 lib/jackhammer/queue.rb