Class: Aws::Sqs::Queue
Constant Summary
collapse
- REQUEST_TTL =
600
Authentication::AMAZON_ACCESS_KEY_ID, Authentication::AMAZON_SECRET_ACCESS_KEY, Authentication::SIGNATURE_VERSION
Instance Attribute Summary collapse
Instance Method Summary
collapse
#aws_access_key_id, #aws_escape, #aws_escape_params, #aws_secret_access_key, #aws_signature, #generate_query, #generate_query_string, #generate_request, #generate_string_to_sign, #new_digest, #sign, #uri_escape_params
Methods included from AWS
#http_get_xml, #time_xml
Constructor Details
#initialize(queue_name = nil) ⇒ Queue
Returns a new instance of Queue.
17
18
19
20
21
|
# File 'lib/lamed/aws/sqs.rb', line 17
def initialize(queue_name = nil)
@host = DEFAULT_HOST
@queue_name = queue_name
@path = queue_name.nil? ? "/" : get_http_path if @path.nil?
end
|
Instance Attribute Details
#expires(time = nil) ⇒ Object
time
is expressed as a string.
123
124
125
|
# File 'lib/lamed/aws/sqs.rb', line 123
def expires
@expires
end
|
#host ⇒ Object
Returns the value of attribute host.
15
16
17
|
# File 'lib/lamed/aws/sqs.rb', line 15
def host
@host
end
|
#path ⇒ Object
Returns the value of attribute path.
15
16
17
|
# File 'lib/lamed/aws/sqs.rb', line 15
def path
@path
end
|
Instance Method Details
#attributes ⇒ Object
53
54
55
56
57
|
# File 'lib/lamed/aws/sqs.rb', line 53
def attributes
action = "GetQueueAttributes"
params = { "AttributeName" =>"All" }.merge(default_params)
http_get_xml(@host, @path, generate_query(action, params))
end
|
#create(queue_name) ⇒ Object
59
60
61
62
63
64
65
|
# File 'lib/lamed/aws/sqs.rb', line 59
def create(queue_name)
action = "CreateQueue"
params = { "QueueName" => queue_name}
params.merge!(default_params)
@path = "/"
http_get_xml(@host, @path, generate_query(action, params))
end
|
#create_request(uri, query_string = nil) ⇒ Object
138
139
|
# File 'lib/lamed/aws/sqs.rb', line 138
def create_request(uri, query_string = nil)
end
|
#default_params ⇒ Object
131
132
133
134
135
136
|
# File 'lib/lamed/aws/sqs.rb', line 131
def default_params
request = {
'Expires' => expires,
'Version' => API_VERSION
}
end
|
#delete(receipt_handle) ⇒ Object
109
110
111
112
113
114
|
# File 'lib/lamed/aws/sqs.rb', line 109
def delete(receipt_handle)
action = "DeleteMessage"
params = { "ReceiptHandle" => receipt_handle }.merge(default_params)
http_get_xml(@host, url_path, generate_query(action, params))
end
|
#delete_queue ⇒ Object
116
117
118
119
120
|
# File 'lib/lamed/aws/sqs.rb', line 116
def delete_queue
action = "DeleteQueue"
params = default_params
http_get_xml(@host, url_path, generate_query(action, params))
end
|
#get_http_path ⇒ Object
Get the queue path using Action = ListQueues
and additional param QueneNamePrefix
. Example response /12345678012/exampleQueue
25
26
27
28
29
30
31
32
33
|
# File 'lib/lamed/aws/sqs.rb', line 25
def get_http_path
action = 'ListQueues'
params = { "QueueNamePrefix" => @queue_name }.merge(default_params)
path = url_path || ""
xml_doc = http_get_xml(@host, path, generate_query(action, params))
url = (xml_doc["ListQueuesResponse"]["ListQueuesResult"]["QueueUrl"])
url = url[0] if Array === url
URI.parse(url).path
end
|
#list_queues(prefix = "") ⇒ Object
List all the queues that start with the prefix.
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/lamed/aws/sqs.rb', line 40
def list_queues(prefix = "")
action = "ListQueues"
@path = "/"
available_queues = Array.new
xml_doc = http_get_xml(@host, path, generate_query(action, default_params))
if xml_doc["ListQueuesResponse"]["ListQueuesResult"]["QueueUrl"]
xml_doc["ListQueuesResponse"]["ListQueuesResult"]["QueueUrl"].each do |url|
available_queues << url.split("/").last
end
end
available_queues
end
|
#message ⇒ Object
97
98
99
|
# File 'lib/lamed/aws/sqs.rb', line 97
def message
@message
end
|
#message_attributes ⇒ Object
105
106
107
|
# File 'lib/lamed/aws/sqs.rb', line 105
def message_attributes
@message_attribute
end
|
#message_body ⇒ Object
101
102
103
|
# File 'lib/lamed/aws/sqs.rb', line 101
def message_body
@message_body
end
|
#receipt_handle ⇒ Object
93
94
95
|
# File 'lib/lamed/aws/sqs.rb', line 93
def receipt_handle
@receipt_handle
end
|
#receive(receive_params = {}) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/lamed/aws/sqs.rb', line 73
def receive(receive_params = {})
action = "ReceiveMessage"
params = {
"MaxNumberOfMessages" => receive_params[:number] || 1,
"AttributeName" => "All" }
params["VisibilityTimeout"] = receive_params[:timeout] if receive_params[:timeout]
params.merge!(default_params)
xml = http_get_xml(@host, url_path, generate_query(action, params))
if !xml["ReceiveMessageResponse"]["ReceiveMessageResult"].nil?
message = xml["ReceiveMessageResponse"]["ReceiveMessageResult"]["Message"]
@message_body = message["Body"]
@message_attribute = message["Attribute"]
@receipt_handle = message["ReceiptHandle"]
@message = message
else
nil
end
end
|
#send(message, send_params = nil) ⇒ Object
67
68
69
70
71
|
# File 'lib/lamed/aws/sqs.rb', line 67
def send(message, send_params = nil)
action = "SendMessage"
params = { "MessageBody" => message }.merge(default_params)
http_get_xml(@host, url_path, generate_query(action, params))
end
|
#url_path ⇒ Object
35
36
37
|
# File 'lib/lamed/aws/sqs.rb', line 35
def url_path
@path || '/'
end
|