Class: Shoryuken::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/shoryuken/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, queue, data) ⇒ Message

Returns a new instance of Message


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/shoryuken/message.rb', line 5

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.loggger.warn do
      '[DEPRECATION] Passing a queue url into Shoryuken::Message is deprecated, please pass the queue itself'
    end
    self.queue_url = queue
  end
end

Instance Attribute Details

#clientObject

Returns the value of attribute client


3
4
5
# File 'lib/shoryuken/message.rb', line 3

def client
  @client
end

#dataObject

Returns the value of attribute data


3
4
5
# File 'lib/shoryuken/message.rb', line 3

def data
  @data
end

#queue_nameObject

Returns the value of attribute queue_name


3
4
5
# File 'lib/shoryuken/message.rb', line 3

def queue_name
  @queue_name
end

#queue_urlObject

Returns the value of attribute queue_url


3
4
5
# File 'lib/shoryuken/message.rb', line 3

def queue_url
  @queue_url
end

Instance Method Details

#attributesObject


58
59
60
# File 'lib/shoryuken/message.rb', line 58

def attributes
  data.attributes
end

#bodyObject


54
55
56
# File 'lib/shoryuken/message.rb', line 54

def body
  data.body
end

#change_visibility(options) ⇒ Object


28
29
30
31
32
# File 'lib/shoryuken/message.rb', line 28

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

#deleteObject


21
22
23
24
25
26
# File 'lib/shoryuken/message.rb', line 21

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

#md5_of_bodyObject


50
51
52
# File 'lib/shoryuken/message.rb', line 50

def md5_of_body
  data.md5_of_body
end

#md5_of_message_attributesObject


62
63
64
# File 'lib/shoryuken/message.rb', line 62

def md5_of_message_attributes
  data.md5_of_message_attributes
end

#message_attributesObject


66
67
68
# File 'lib/shoryuken/message.rb', line 66

def message_attributes
  data.message_attributes
end

#message_idObject


42
43
44
# File 'lib/shoryuken/message.rb', line 42

def message_id
  data.message_id
end

#receipt_handleObject


46
47
48
# File 'lib/shoryuken/message.rb', line 46

def receipt_handle
  data.receipt_handle
end

#visibility_timeout=(timeout) ⇒ Object


34
35
36
37
38
39
40
# File 'lib/shoryuken/message.rb', line 34

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