Support of AWS SQS for Node.js - TypeScript

Support for AWS SQS is available from version 1.7.0-beta3 of the com.castsoftware.typescript extension. SQS is currently supported only for SQS queues created using SDK.

Objects

Icon Description

Node.js AWS SQS Publisher

Node.js AWS SQS Receiver

Node.js AWS SQS Unknown Publisher

Node.js AWS SQS Unknown Receiver
Link Type Function
callLink

sendMessage

sendMessageBatch

receiveMessage

Support for SDK

This code will publish a message into the “SQS_QUEUE_URL” queue:

import * as AWS from "aws-sdk";
AWS.config.update({ region: 'REGION' });

const sqs = new AWS.SQS({apiVersion: '2012-11-05'});

const queueUrl = "SQS_QUEUE_URL"

const params = {
    MessageBody: "This is a message",
    QueueUrl: queueUrl,
    MaxNumberOfMessages: 1,
    VisibilityTimeout: 0,
};


sqs.sendMessage(params, function (err, data) {
    if (err) {
        console.log("Error", err);
    } else {
        console.log("Success", data.MessageId);
    }
});
}

This code will receive a message from the queue “SQS_QUEUE_URL”

import * as AWS from "aws-sdk";
AWS.config.update({ region: 'REGION' });

const sqs = new AWS.SQS({apiVersion: '2012-11-05'});

const queueUrl = "SQS_QUEUE_URL"

const params = {
    QueueUrl: queueUrl,
    MaxNumberOfMessages: 1,
    VisibilityTimeout: 0,
};

export class SqsReciver {
    constructor() {
        this.reciver();
    }
    private reciver(): void {
        sqs.receiveMessage(params, (err, data) => {
    // do something
        });
    }
}

Known limitations

  • The use of AWS.SQS with promises is not supported. For instance no link would be created between the receiver and the handler function defined in .then() call in the following source code: 
this.sqs.receiveMessage(params).promise().then( () => {})
  • If the queueName is set using the createQueue api, the evaluation of the queue name will fail.