-
Notifications
You must be signed in to change notification settings - Fork 16
/
sqs.aws.txt
198 lines (176 loc) · 12.8 KB
/
sqs.aws.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
SQS
SQS ==> #Version from 2014-07-16
GOAL ==> #Message passing between components/apps.
QUEUE ==> #Several messages:
# - MessageRetentionPeriod: how long queue retains messages (in secs).
# From 1 min to 2 weeks. Def: 4 days.
# - erased if no Send|Receive|DeleteMessage(), Get|SetQueueAttributes() or
# Add|RemovePermission() in one month
MESSAGE ==> #SendMessage(): queue in (writes)
# - DelaySeconds: how long between SendMessage() and actual queueing in (0 (def) to 900, in secs)
# - MessageAttributes: metadata, must [[:alnum:]-.]
# - MaximumMessageSize: 1 KiB to 256 KiB (def). Above: rejected, not truncated.
# - not guaranteed to be queued in same order as sent
# - might on rare occasions duplicate messages
#ReceiveMessage(): locks (reads)
# - not guaranteed to be received same order as queued in
# - Can either do:
# - short polling ([ReceiveMessage]WaitTimeSeconds 0) (def):
# - queries only a random sample of servers, so might return empty even if there are
# messages
# - long polling ([ReceiveMessage]WaitTimeSeconds 1-20)
# - queries all servers, so does not return empty if there are messages
# - WaitTimeSeconds is actually only max time
# - VisibilityTimeout:
# - how long to lock messages (0 to 12 hours, def: 30 secs)
# - should be:
# - above the time to process the message
# - not 0, otherwise will return duplicates
# - if different messages with different processing times, should try to create different
# queues with default VisibilityTimeout instead of overriding it in ReceiveMessage()
# - ChangeMessageVisibility(): change message VisibilityTimeout and reset timeout spent.
# Can set to 0 to force timeout.
# - MaxNumberOfMessages: to receive several messages at once. Max, can be fewer (1 (def) to 10)
# - Dead letter queue: for "stuck" messages
# - after NUM ReceiveMessage() without DeleteMessage(), put in a separate queue
# - Uses RedrivePolicy.maxReceiveCount NUM (1 to 1000) (def: none) and
# RedrivePolicy.deadLetterTargetArn QUEUE_ARN
#DeleteMessage(): queue out
#Send|DeleteMessageBatch(): allow doing several operations at once (cheaper)
CLOUDWATCH ==> #Only collected if queue had any API call for the last 6 hours.
# - METRIC:
# - NumberOfMessagesSent|Received|Deleted NUM
# - SentMessageSize NUM
# - NumberOfEmptyReceives NUM
# - ApproximateNumberOfMessages[Not]Visible|Delayed NUM
# - Dimensions: QueueName
PRICING ==> # - 1$/2M API calls (if more than 64KB, 1 API call for each 64KB) (first 1M free)
# - Data transfer:
# - in: free
# - out: 1$/8GB/month (first 1GB/month free)
/=+===============================+=\
/ : : \
)==: API :==(
\ :_______________________________: /
\=+===============================+=/
API ==> #XML not JSON.
# - ARR.member.NUM (REST API) -> ARR (SDKs)
ARN ==> # - arn:aws:sqs:*:ACCOUNT_ID:QUEUE_NAME
# - Can assign policies to resources (queues):
# - use Principal, including "*" (anonymous)
# - def. policy for resource is empty (only creator can use it)
# - can either:
# - set manually with SetQueueAttributes()
# - use simpler interface Add|RemovePermission(), which sets a simple policy with:
# - Id "arn:aws:sqs:REGION:ACCOUNT_ID/QUEUE/SQSDefaultPolicy"
# - Sid STR (use Label STR)
# - Effect "Allow"
# - Principal: { "AWS": STR[_ARR] }
# - Action: ACTION
# - Resource QUEUE_ARN
LIMIT ==> # - 10 MessageAttributes per message
# - 256KB message size (including full size of SendMessageBatch())
# - 120000 messages received but not deleted per queue
/=+===============================+=\
/ : : \
)==: METHODS :==(
\ :_______________________________: /
\=+===============================+=/
CreateQueue() #Request parameters:
# - QueueName STR
# - Attributes ATTR:
# - DelaySeconds NUM
# - MaximumMessageSize NUM
# - MessageRetentionPeriod NUM
# - Policy STR: IAM policy, URL-encoded
# - RedrivePolicy JSON_STR: URL-encoded
# - ReceiveMessageWaitTimeSeconds NUM
# - VisibilityTimeout NUM
#Response body: QueueUrl URL: is queue ID
DeleteQueue() #Request parameters: QueueUrl URL
SetQueueAttributes() #Request parameters:
# - QueueUrl URL
# - Attributes ATTR
GetQueueAttributes() #Request parameters:
# - QueueUrl URL
# - AttributeNames ATTR_VAR_STR_ARR (can also be "All"), with also:
# - ApproximateNumberOfMessages[NotVisible] NUM
# - ApproximateNumberOfMessagesDelayed NUM
# - Created|LastModifiedTimestamp DATE_NUM
# - QueueArn
#Response body: Attributes ATTR
GetQueueUrl() #Request parameters:
# - QueueName STR
# - QueueOwnerAWSAccountId STR
#Response body: QueueUrl URL
ListQueues() #Request parameters: QueueNamePrefix STR
#Response body: QueueUrls URL_ARR
ListDeadLetterSourceQueues() #Request parameters: QueueUrl URL
#Response body: QueueUrls URL_ARR
SendMessage() #Request parameters MESSAGE:
# - QueueUrl URL
# - MessageBody STR
# - MessageAttributes METADATA:
# - VAR:
# - DataType "String|Binary[.CUSTOM]"
# - BinaryValue BUFFER|TYPEDARRAY|BLOB
# - StringValue STR
# - DelaySeconds NUM
#Response body:
# - MessageId STR
# - MD5OfMessageBody|Attributes STR
SendMessageBatch() #Request parameters:
# - QueueUrl URL
# - Entries OBJ_ARR (SendMessageBatchRequestEntry in REST API):
# - Same members as MESSAGE but QueueUrl -> Id
#Response body SUCCESS_OR_FAIL:
# - Successful|Failed OBJ_ARR:
# - Id STR
# - SenderFault BOOL (if Failed)
ReceiveMessage() #Request parameters:
# - QueueUrl URL
# - AttributeNames STR_ARR: "All" or among any VAR of MESS_ATTR
# - MessageAttributeNames METADATA_VAR_STR_ARR (can also be "All")
# - MaxNumberOfMessages NUM
# - VisibilityTimeout NUM
# - WaitTimeSeconds NUM
#Response body: Messages OBJ_ARR:
# - MessageId STR
# - ReceiptHandle STR
# - MD5OfMessageBody|Attributes STR
# - Attributes MESS_ATTR:
# - ApproximateFirstReceiveTimestamp DATE_NUM
# - SentTimestamp DATE_NUM
# - SenderId (ACCOUNT_ID or (if anonymous) IP)
# - ApproximateReceiveCount NUM
# - MessageAttributes METADATA
DeleteMessage() #Request parameters:
# - QueueUrl URL
# - ReceiptHandle STR
DeleteMessageBatch() #Request parameters:
# - QueueUrl URL
# - Entries OBJ_ARR:
# - Id STR
# - ReceiptHandle STR
#Response body SUCCESS_OR_FAIL
ChangeMessageVisibility() #Request parameters:
# - QueueUrl URL
# - VisibilityTimeout NUM
# - ReceiptHandle STR
ChangeMessageVisibilityBatch()#Request parameters:
# - QueueUrl URL
# - Entries OBJ_ARR (ChangeMessageVisibilityBatchRequestEntry in REST API):
# - Id STR
# - ReceiptHandle STR
# - VisibilityTimeout NUM
#Response body SUCCESS_OR_FAIL
AddPermission() #Request parameters:
# - QueueUrl URL
# - AWSAccountIds STR_ARR
# - Actions ACTION_STR_ARR
# - Label STR
RemovePermission() #Request parameters:
# - QueueUrl URL
# - Label STR