Sha256: 8ad7e479c1227c4bcecbb9440eb0731f0a80f6eb73a8f513e3a1afc1ba81cce4

Contents?: true

Size: 1.44 KB

Versions: 7

Compression:

Stored size: 1.44 KB

Contents

module Shoryuken
  class Message
    attr_accessor :client, :queue_url, :queue_name, :data

    def initialize(client, queue, data)
      self.client = client
      self.data = data

      if queue.is_a?(Shoryuken::Queue)
        self.queue_url = queue.url
        self.queue_name = queue.name
      else
        # TODO: Remove next major release
        Shoryuken.logger.warn do
          '[DEPRECATION] Passing a queue url into Shoryuken::Message is deprecated, please pass the queue itself'
        end
        self.queue_url = queue
      end
    end

    def delete
      client.delete_message(
        queue_url: queue_url,
        receipt_handle: data.receipt_handle
      )
    end

    def change_visibility(options)
      client.change_message_visibility(
        options.merge(queue_url: queue_url, receipt_handle: data.receipt_handle)
      )
    end

    def visibility_timeout=(timeout)
      client.change_message_visibility(
        queue_url: queue_url,
        receipt_handle: data.receipt_handle,
        visibility_timeout: timeout
      )
    end

    def message_id
      data.message_id
    end

    def receipt_handle
      data.receipt_handle
    end

    def md5_of_body
      data.md5_of_body
    end

    def body
      data.body
    end

    def attributes
      data.attributes
    end

    def md5_of_message_attributes
      data.md5_of_message_attributes
    end

    def message_attributes
      data.message_attributes
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
shoryuken-2.1.3 lib/shoryuken/message.rb
shoryuken-2.1.2 lib/shoryuken/message.rb
shoryuken-2.1.1 lib/shoryuken/message.rb
shoryuken-2.1.0 lib/shoryuken/message.rb
shoryuken-2.0.11 lib/shoryuken/message.rb
shoryuken-2.0.4 lib/shoryuken/message.rb
shoryuken-2.0.3 lib/shoryuken/message.rb