Sha256: 346e9f35245a5b06add4e62b85283d3068c92772d9a4f81145ed078e236319c5

Contents?: true

Size: 1.32 KB

Versions: 8

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

module Basquiat
  module Adapters
    class RabbitMq
      # A RabbitMQ message, with it's delivery info and properties
      # It's used instead of a simple hash so we can access more easily
      # the properties needed for acks and requeues
      class Message < Basquiat::Adapters::BaseMessage
        attr_reader :delivery_info, :props
        alias di delivery_info
        # @!attribute [r] delivery_info
        #   @return [Hash] RabbitMQ delivery_info.
        # @!attribute [r] props
        #   @return [Hash] RabbitMQ message properties, such as headers.

        def initialize(message, delivery_info = {}, props = {})
          super(message)
          @delivery_info = delivery_info
          @props         = props
          @action        = :ack
        end

        # @!attribute [rw] routing_key
        #   It overrides (but not overwrites) the delivery_info routing_key
        #   @return [String] returns either the set routing_key or the delivery_info routing_key
        attr_writer :routing_key
        def routing_key
          @routing_key || delivery_info.routing_key
        end

        # Shorthand for delivery_info.delivery_tag
        # @return [String] the message's Delivery Tag
        def delivery_tag
          delivery_info.delivery_tag
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
basquiat-1.6.0 lib/basquiat/adapters/rabbitmq/message.rb
basquiat-1.5.2 lib/basquiat/adapters/rabbitmq/message.rb
basquiat-1.5.1 lib/basquiat/adapters/rabbitmq/message.rb
basquiat-1.5.0 lib/basquiat/adapters/rabbitmq/message.rb
basquiat-1.4.0 lib/basquiat/adapters/rabbitmq/message.rb
basquiat-1.3.6 lib/basquiat/adapters/rabbitmq/message.rb
basquiat-1.3.5 lib/basquiat/adapters/rabbitmq/message.rb
basquiat-1.3.4 lib/basquiat/adapters/rabbitmq/message.rb