Menu
Enter the Endpoint as a URL for the AWS SQS queue service. Provide the Access Key, which is an AWS access key ID. You use access keys to sign programmatic requests that you make to AWS if you use AWS CLI commands or using AWS API operations.You must use both the access key and secret access key together to authenticate your requests.
Setting up your own server will require good knowledge of the subject so that you do not leave any corner untouched. This is not the case with Amazon SQS as it is pretty quick to get started with.
The beauty of SQS is also that things do not get lost–independent of any server–and also it eliminates two threads trying to do the same job and bumping heads.
Once anything receives the message in the queue, they have an exclusive lease on it for a certain period of time. This makes it especially great once you need to scale to multiple worker servers. Each one just gets the next job in the queue and does its thing, independent of any of the others, and then removes it from the queue once done(from Jason Byrne).
Remark:
— Before starting steps below, Clone Sample Git, and do npm install.
Step:
- set up access-key and secret-key
- $ node sqs_createqueue.js
- $ node sqs_listqueues.js
- $ node sqs_getqueueurl.js (the reture url is used in step 5 and 6)
- $ node sendMessage.js
- $ node receiveMessage.js
1- set up access-key and secret-key
Go to IAM management console to create an user whom the system is going to generate access-key and secret-key to (for more information).
Before creating the user, a configured group with SQS permission is required. In the permission windows, select the click-box for AmazonSQSFullAccess, and next.
Add user to the group with access SQS permission.
Generating access-key and secret-key, which will be used in config.json later.
Create a config.json file under the Node.js directory, in which paste the access-key and secret-key which generated from the previous step to field accessKeyId and secretAccessKey.
2- Creating Queue
Amazon not only brings us diverse Another great things Amazon provides us are, very easy to read documentation and super easy to use sample code. With the doc and git example, running the Helloworld example, sending/receiving message is just a piece of cake.
Creating a Queue
run sqs_createqueue.js file
List Queue
Get Queue Url
In sendMessage.js, set value to valuable QueueUrl from the return result, and the message “Information about current NY Times…” is going to be sent:
Sending Message to Queue
Receiving Message from Queue
In receiveMessage.js, Set value to QueueUrl from the sqs_getqueueurl.js result:
Note
Message Attribute VS Message Body
— Message attributes are supposed to be used as message metadata (like timestamp or possibly some category) and not the message itself.
--