Class SQS
Defined in: sqs.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
SQS(accessKeyId, secretAccessKey, opts)
Simple Queue Service, used to communicate and run commands against Amazon's SQS. |
| Method Attributes | Method Name and Description |
|---|---|
|
createQueue(name, attrs, fn)
Create a SQS queue |
|
|
deleteMessage(queue, messageReceipt, fn)
Deletes a message from a queue. |
|
|
deleteMessageBatch(queue, messageReceipts, fn)
Deletes a batch of messages from a queue. |
|
|
deleteQueue(name, fn)
Deletes a SQS queue. |
|
|
getQueueUrl(name, fn)
Returns the full qualified url for a queue. |
|
|
listQueues(prefix, fn)
Returns a list of available queues. |
|
|
receiveMessage(queue, opts, fn)
Retrieves any messages from a queue if any are available. |
|
|
sendMessage(queue, message, delay, fn)
Sends a message to a queue. |
|
|
sendMessageBatch(queue, messages, fn)
Sends a batch of messages to a queue. |
SQS(accessKeyId, secretAccessKey, opts)
Simple Queue Service, used to communicate and run commands against Amazon's SQS.
var sqs = new SQS('awsId', 'awsSecret');
- Parameters:
- {string} accessKeyId
- key id
- {string} secretAccessKey
- secret access key
- {object} opts Optional
- optional parameters
- {string} opts.region Optional
- the aws region, must be one of these: us-east-1, us-west-1, us-west-2, eu-west-1, ap-southeast-1, ap-northeast-1
createQueue(name, attrs, fn)
Create a SQS queue
- Parameters:
- {string} name
- The name of the queue Constraints: Maximum 80 characters; alphanumeric characters, hyphens (-), and underscores (_) are allowed.
- {object} attrs Optional
- Attributes for the queue.
- {number} attrs.VisibilityTimeout Optional
- The length of time (in seconds) that a message received from a queue will be invisible to other receiving components when they ask to receive messages. For more information about VisibilityTimeout, see Visibility Timeout in the Amazon SQS Developer Guide. An integer from 0 to 43200 (12 hours). The default for this attribute is 30.
- {string} attrs.Policy Optional
- The formal description of the permissions for a resource. For more information about Policy, see Basic Policy Structure in the Amazon SQS Developer Guide. A valid form-url-encoded policy. For more information about policy structure, see Basic Policy Structure in the Amazon SQS Developer Guide. For more information about form-url-encoding, see http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2.1.
- {number} attrs.MaximumMessageSize Optional
- The limit of how many bytes a message can contain before Amazon SQS rejects it. An integer from 1024 bytes (1 KiB) up to 65536 bytes (64 KiB). The default for this attribute is 65536 (64 KiB).
- {number} attrs.MessageRetentionPeriod Optional
- The number of seconds Amazon SQS retains a message. Integer representing seconds, from 60 (1 minute) to 1209600 (14 days). The default for this attribute is 345600 (4 days).
- {number} attrs.DelaySeconds Optional
- The time in seconds that the delivery of all messages in the queue will be delayed. An integer from 0 to 900 (15 minutes). The default for this attribute is 0 (zero).
- {Function} fn
- Callback function for when queue is created, Callback function takes two parameters error and result, result will be full name for the queue.
- See:
- SQS.prototype.deleteQueue
deleteMessage(queue, messageReceipt, fn)
Deletes a message from a queue.
- Parameters:
- {string} queue
- The full name of the queue to delete the message from, name should be something like /1212412123/nameOfQueue.
- {string} messageReceipt
- The message receipt of the message to delete.
- {Function} fn
- Callback function for deleting a message, callback will include an err (or null).
- See:
- SQS.prototype.deleteMessage
deleteMessageBatch(queue, messageReceipts, fn)
Deletes a batch of messages from a queue.
- Parameters:
- {string} queue
- The full name of the queue to delete the message from, name should be something like /1212412123/nameOfQueue.
- {Array} messageReceipts
- An array of message receipts to delete from the queue.
- {Function} fn
- Callback function for deleting messages, callback will include an err (or null).
- See:
- SQS.prototype.deleteMessageBatch
deleteQueue(name, fn)
Deletes a SQS queue.
- Parameters:
- {string} name
- The full name for the queue, should be something like /12312301239/nameOfQueue.
- {Function} fn
- Callback function for when queue is created Callback function takes one parameter, error
- See:
- SQS.prototype.createQueue
getQueueUrl(name, fn)
Returns the full qualified url for a queue.
- Parameters:
- {string} name
- The full name of the queue, should be something like /12312301239/nameOfQueue.
- {Function} fn
- The callback for when the url is retrieved, Callback function should take two parameters, error and result which is queue url
- See:
- SQS.prototype.listQueues
listQueues(prefix, fn)
Returns a list of available queues.
- Parameters:
- {string} prefix Optional
- Queue name prefix to filter the list of queues to return.
- {Function} fn
- The callback for when the queue list is retrieved, Callback function should take two parameters, error and result which is an array of queue names
- See:
- SQS.prototype.getQueueUrl
receiveMessage(queue, opts, fn)
Retrieves any messages from a queue if any are available. If none are available then an empty array is returned as the result.
- Parameters:
- {string} queue
- The full name of the queue to check for messages, should look something like /12312301239/nameOfQueue.
- {object} opts Optional
- Options for retreiving messages.
- {number} opts.MaxNumberOfMessages Optional
- The max number of messages to pull from queue.
- {number} opts.VisibilityTimeout Optional
- The length of time in seconds that a message is not visible for receive requests after returned from this one.
- {Function} fn
- The callback for when the message(s) are pulled from queue, Callback function should take two parameters, error and result which is an array of messages.
- See:
- SQS.prototype.sendMessage
sendMessage(queue, message, delay, fn)
Sends a message to a queue.
- Parameters:
- {string} queue
- The full name of the queue. Should be something like /12312301239/nameOfQueue.
- {string} message
- The message to add to the queue.
- {number} delay Optional
- The delay to wait before the message is actually visible in the queue.
- {Function} fn
- The callback for when the message is add to queue, Callback function should take two parameters, error and result which is and the message details.
- See:
- SQS.prototype.sendMessageBatch
sendMessageBatch(queue, messages, fn)
Sends a batch of messages to a queue.
- Parameters:
- {string} queue
- The full name of the queue. Should be something like /12231231231/nameOfQueue.
- {Array} messages
- An array of objects, each object should have message property and optional delay property.
- {Function} fn
- The callback for when the message is add to queue, Callback function should take two parameters, error and result which is an array of message details.
- See:
- SQS.prototype.sendMessage