Introduction

E2E Queue service (EQS) lets you send, store, and recieve message between parts of your application or components. This is E2E EQS compliant, high performant, and reliable service which can be used for high volume of send/receive between various components in your software stack.

How to Create EQS ?

Click on Compute from the side navbar.

../_images/eqs1.png

Under the compute section user will be able to see an EQS service and users have to click on EQS.

../_images/eqs2.png

After clicking on the EQS the page will be redirected to EQS page and for creating EQS users have to click on Create Queue Service button

../_images/eqs3.png

After clicking on create EQS service the EQS creation form will be open and on that page the user can give the name of EQS and select the plan as per his requirement and can also use VPC. After filling details users have to click on the Create button.

../_images/eqs4.png

After clicking on the Create button the EQS service will be created and it will be shown in the list.

../_images/eqs5.png

Actions

You can perform the following actions available for the respective EQS.

../_images/eqs6.png

Add Queue

For creating Queue user have to click on Add Queue button.

../_images/eqs7.png

Creds

To see the credentials (like access key and secret key) you have to click on the creds button under Actions.

../_images/eqs8.png

After clicking on the creds button a pop will appear in which the user will be able to see the credentials.

../_images/eqs9.png

Delete

To delete your EQS click on the Delete button under Actions.

../_images/eqs10.png

After clicking on the delete button a pop will open click on the Delete button again to delete the Queue Service.

../_images/eqs11.png

Add Queue under tab

For adding a queue under created EQS, users have to click on the Add Queue button.

../_images/eqs12.png

After clicking on the Add Queue button. A pop-up will open, give a name of your queue and click on Add button.

../_images/eqs13.png

After giving a Queue name click on Add button.

../_images/eqs14.png

After creating a queue. It will be shown in the list under created EQS

../_images/eqs15.png

Actions for queue service:

You can perform the following actions for the respective Queue.

../_images/eqs16.png

Test Send Message

User can send a message by clicking on Test send message.

../_images/eqs17.png

After clicking on Test send a message a pop-up will open leave a message and set time delay and then click on send button

../_images/eqs18.png

Purge

To purge a queue click on the purge button.

../_images/eqs19.png

After clicking on the purge button a pop will appear click on the Ok button to continue.

../_images/eqs20.png

Delete

To delete a Queue click on the Delete button.

../_images/eqs21.png

After clicking on the delete button a pop-up will appear click on delete button again to delete the queue.

../_images/eqs21.png

Using SDK

Python SDK

1- Go to your project directory

2- Make your virtual Environment and activate it

3- Install Boto3 into your virtual Environment

pip install boto3

4- Make a connection with the EQS client.

To make the connection with the EQS client , you need to pass configurations and credentials.

Configurations-

region_name- your_region
endpoint_url - eqs_endpoint_url (provided by e2e networks eqs service)

Credentials-

aws_access_key_id - your_access_key_id
aws_secret_key_id - your_secret_key_id

Make connection with EQS

You can make the connection with the EQS client in three ways

a) You can directly pass the credentials and configurations at the time of making a session with the EQS client. warning - Hardcoded credentials in application is not recommended

import boto3

session = boto3.Session()

eqs_client=session.client(
        “sqs”,
        aws_access_key_id = your_access_key_id,
        aws_secret_access_key = your_secret_key,
        region_name = your_region,
        endpoint_url = eqs_endpoint_url
)

You can also pass credentials and configurations inside boto3.Session() instead of session.client()

b) you can put credentials and configurations in the config and credentials file , and these files should be located at ~/.aws/config, ~/.aws/credentials location.

put into ~/.aws/config file

[default]
region =REGION

put into ~/.aws/credentials file

[default]
aws_access_key_id = ACCESS_KEY_ID
aws_secret_access_key = SECRET_KEY
import boto3

session = boto3.Session()

eqs_client=session.client(
        “sqs”,
        endpoint_url = EQS_ENDPOINT_URLl
)

This will include configurations and credentials in the client by default.

c) you can make the connection with the EQS client by passing the credentials and configuration into the environment variables file.

To install the python dotenv package, you can use the command

pip install python-dotenv

using terminal (Linux, OS X or Unix)

$ export AWS_ACCESS_KEY_ID = your_access_key_id
$ export AWS_SECRET_ACCESS_KEY = your_secret_key
$ export AWS_DEFAULT_REGION = your_eqs_region

using terminal (Windows)

> set AWS_ACCESS_KEY_ID = your_access_key_id
> set AWS_SECRET_ACCESS_KEY = your_secret_key
> set AWS_DEFAULT_REGION = your_eqs_region

or, edit your enviourment valiable file

AWS_ACCESS_KEY_ID = your_access_key_id
AWS_SECRET_ACCESS_KEY = your_secret_access_key
AWS_DEFAULT_REGION = your_eqs_region
import boto3
import os
from dotenv import load_dotenv

load_dotenv()

session = boto3.Session(aws_access_key_id = os.environ.get(“AWS_ACCESS_KEY_ID”),
        aws_secret_access_key = os.environ.get(“AWS_SECRET_ACCESS_KEY”),
        region_name = os.environ.get(“AWS_DEFAULT_REGION”)
        )

eqs_client=session.client(
        “sqs”,
        endpoint_url = EQS_ENDPOINT_URL
        )

above eqs_client is an object which has all methods related to queue operations.

response of session.client()

../_images/make_connection_boto3.png

Methods available in eqs_client

Change VisibilityTimeout

Request Syntax

response = eqs_client.change_message_visibility(
        QueueUrl='string',
        ReceiptHandle='string',
        VisibilityTimeout=123
        )

Parameters

QueueUrl (string)- [Required]

The URL of the E2E EQS queue whose message’s visibility is changed.

ReceiptHandle (string) - [Required]

The receipt handle is associated with the message whose visibility timeout is changed. This parameter is returned by the ReceiveMessage action

VisibilityTimeout (integer) - [Required]

The new value for the message’s visibility timeout (in seconds)

Response Syntax

None
../_images/tag_queue_boto3.png

Change VisibilityTimeout in batch

Request Syntax

response = eqs_client.change_message_visibility_batch(
        QueueUrl="string",
        Entries=[
                {"Id": "string", "ReceiptHandle": "string", "VisibilityTimeout": 123},
        ],
)

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue whose message’s visibility is changed.

Entries (list) - [Required]

(Dictionary)

id [Required]-(string) An identifier for this particular receipt handle used to communicate the result

ReceiptHandle [Required] -(string) A receipt handle

VisibilityTimeout - (string) The new value (in seconds) for the message’s visibility timeout

Response Syntax

{
    "Successful": [{"Id": "string"}, ],
    "Failed": [
                {
                "Id": "string",
                "SenderFault": True | False,
                "Code": "string",
                "Message": "string",
                },
      ],
}
../_images/change_visibility_timeout_batch_boto3.png

Close connection

Request Syntax

eqs_client.close()

Response Syntax

None

Create queue

Request Syntax

response = eqs_client.create_queue(
        QueueName="string",
        Attributes={"string": "string"},
        tags={"string": "string"}
)

Parameters

QueueName (string)- [Required]

1 - A queue name can have up to 80 characters

2 - Valid values: alphanumeric characters, hyphens ( -), and underscores ( _).

Attributes (dictionary)- Attributes could be

1 - DelaySeconds - Time(second), to which extent delivery of messages is delayed in the queue

Valid values - 0 to 900 (second)

default - 0 (second)

2 - MaximumMessageSize - The size of the message after which the queue will reject the message

Valid values - 1,024 bytes (1 KiB) to 262,144 bytes (256 KiB)

default - 262,144 bytes(256 KiB)

3 - MessageRetentionPeriod - Time to which extent a queue will retain a message

Valid values - 60 seconds (1 minute) to 1,209,600 seconds (14 days)

default - 345,600 (4 days)

4 - ReceiveMessageWaitTimeSeconds - Time to which extent ReceiveMessage action waits before receiving a message

Valid values - 0 to 20 (seconds)

default - 0 (second)

5 - VisibilityTimeout - The amount of time that a message in a queue is invisible to other consumers after a consumer retrieves it.

Valid values - 0 to 43,200 seconds (12 hours)

default - 30 second

tags (dictionary ) -

1 - Adding more than 50 tags to a queue isn’t recommended.

2 - A new tag with a key identical to that of an existing tag overwrites the existing tag.

Response Syntax

{ 'QueueUrl': 'string' }
../_images/make_queue_boto3.png

Delete message

Request Syntax

response = eqs_client.delete_message(
        QueueUrl='string',
        ReceiptHandle='string'
)

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which messages are deleted.

ReceiptHandle (string) - [Required]

The receipt handle is associated with the message to delete.

Response Syntax

None
../_images/delete_message_boto3.png

Delete message in batch

Request Syntax

response = eqs_client.delete_message_batch(
        QueueUrl="string",
        Entries=[
                {"Id": "string", "ReceiptHandle": "string"},
        ],
)

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which messages are deleted.

Entries (list) - [Required]

(Dictionary) id [Required]-(string) An identifier for this particular receipt handle used to communicate the result ReceiptHandle [Required] -(string) A receipt handle

Response Syntax

{
   "Successful": [{"Id": "string"}, ],
   "Failed": [
        {
           "Id": "string",
           "SenderFault": True | False,
           "Code": "string",
           "Message": "string",
        },
        ],
}
../_images/delete_message_queue_batch.png

Delete queue

Request Syntax

response = eqs_client.delete_queue(
        QueueUrl='string'
)

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue to delete.

Response Syntax

None

Get queue attributes

Request Syntax

response = eqs_client.get_queue_attributes(
        QueueUrl="string",
        AttributeNames=[ "All", ],
)

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which attributes are get.

AttributeNames (list) - [Optional]

A list of attributes for which to retrieve information

All - it specifies, returns all values

you can also specify specific attributes in the list

As - [‘VisibilityTimeout’ , ‘MaximumMessageSize’ , ‘MessageRetentionPeriod’ , ‘ApproximateNumberOfMessages’ ,’ApproximateNumberOfMessagesNotVisible’ , ‘CreatedTimestamp’ , ‘LastModifiedTimestamp’ , ‘QueueArn’ , ‘ApproximateNumberOfMessagesDelayed’ , ‘DelaySeconds’ , ‘ReceiveMessageWaitTimeSeconds’]

Response Syntax

{
  "Attributes": {"string": "string"}
}
../_images/get_queue_attributes_boto3.png

Get queue url

Request Syntax

response = eqs_client.get_queue_url(QueueName='string',)

Parameters

QueueName (string) -[Required]

The name of the queue whose URL must be fetched.

Response Syntax

{'QueueUrl': 'string'}
../_images/queue_url_boto3.png

List queue tags

Request Syntax

response = eqs_client.list_queue_tags(QueueUrl='string')

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue of which all the tags must be listed.

Response Syntax

{
  'Tags': {'string': 'string'}
}
../_images/list_queue_tags_boto3.png

List queues

Request Syntax

response = eqs_client.list_queues(
        QueueNamePrefix='string',
        MaxResults=123
)
Parameters
QueueNamePrefix (string) - [Optional]

A string to use for filtering the list results. Only those queues whose name begins with the specified string are returned.

MaxResults (integer) - [Optional]

The maximum number of results to include in the response. Valid values - 1 to 1000

Response Syntax

{
  "QueueUrls": ["string", ],
}
../_images/list_queues_boto3.png

Purge queue

delete all the messages from queue.

Request Syntax

response = eqs_client.purge_queue(QueueUrl='string')

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue of which all the messages must be deleted.

Response Syntax

None
../_images/purge_queue_boto3.png

Receive message

Request Syntax

response = eqs_client.receive_message(
        QueueUrl="string",
        AttributeNames=[All],
        MessageAttributeNames=[
                "string",
        ],
        MaxNumberOfMessages=2,
        VisibilityTimeout=25,
        WaitTimeSeconds=10,
        ReceiveRequestAttemptId="string",
)

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which messages are received.

AttributeNames (list) -

A list of attributes that need to be returned along with each message.

All - it specifies, returns all values

you can also specify specific attributes in the list

As - [‘VisibilityTimeout’ , ‘MaximumMessageSize’ , ‘MessageRetentionPeriod’ , ‘ApproximateNumberOfMessages’ ,’ApproximateNumberOfMessagesNotVisible’ , ‘CreatedTimestamp’ , ‘LastModifiedTimestamp’ , ‘QueueArn’ , ‘ApproximateNumberOfMessagesDelayed’ , ‘DelaySeconds’ , ‘ReceiveMessageWaitTimeSeconds’]

MessageAttributeNames (list) -

The name of the message attribute.

MaxNumberOfMessages (integer) -

The maximum number of messages to return.

Valid range - 1 to 10

default - 1

VisibilityTimeout (integer) -

The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request.

WaitTimeSeconds (integer) -

The duration (in seconds) for which the call waits for a message to arrive in the queue before returning.

Response Syntax

{
  "Messages": [
        {
           "MessageId": "string",
           "ReceiptHandle": "string",
           "MD5OfBody": "string",
           "Body": "string",
           "Attributes": {"string": "string"},
           "MD5OfMessageAttributes": "string",
           "MessageAttributes": {
                  "string": {
                          "StringValue": "string",
                          "BinaryValue": b"bytes",
                          "DataType": "string",
                    }
           },
        },
  ]
}
../_images/receive_message_boto3.png

Send message

Request Syntax

response = eqs_client.send_message(
        QueueUrl="string",
        MessageBody="string",
        DelaySeconds=123,
        MessageAttributes={
           "string": {
                  "StringValue": "string",
                  "BinaryValue": b"bytes",
                  "DataType": "string",
            }
        },
        MessageSystemAttributes={
           "string": {
                  "StringValue": "string",
                  "BinaryValue": b"bytes",
                  "DataType": "string",
            }
        },
)

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue to which messages are send.

MessageBody (string) - [Required]

The message to send. The minimum size is one character. The maximum size is 256 KB.

DelaySeconds (integer) -

The length of time, in seconds, for which to delay a specific message.

MessageAttributes (dictionary) -

Each message attribute consists of a Name, Type, and Value .

Name, type, value and the message body must not be empty or null .

(string) - name of the message attributes

(dictionary) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data,

encrypted data, or images.

(string) - [Required] Type of message attributes

EQS support the following data type

Binary, Number, String

MessageSystemAttributes (dictionary) -

Each message system attribute consists of a Name, Type, and Value.

The name, type, value and message body must not be empty or null.

(string) - the name of the message attributes

(dictionary) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data,

encrypted data, or images.

(string) - Type of message attributes

EQS support the following data type

Binary , Number , String

Response Syntax

{
   'MD5OfMessageBody': 'string',
   'MD5OfMessageAttributes': 'string',
   'MD5OfMessageSystemAttributes': 'string',
   'MessageId': 'string',
   'SequenceNumber': 'string'
}
../_images/receive_message_boto3.png

Send message in batch

Request Syntax

response = eqs_client.send_message_batch(
        QueueUrl="string",
        Entries=[
          {
                "Id": "string",
                "MessageBody": "string",
                "DelaySeconds": 123,
                "MessageAttributes":
                {
                   "string": {
                          "StringValue": "string",
                          "BinaryValue": b"bytes",
                          "DataType": "string",
                    }
                },
                "MessageSystemAttributes":
                {
                   "string": {
                          "StringValue": "string",
                          "BinaryValue": b"bytes",
                          "DataType": "string",
                    }
                },
          },
        ],
)

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue to which messages are sent.

Entries (list) - [Required]

A list of SendMessageBatchRequestEntry items.

(Dict) -

Contains the details of a single E2E EQS message along with an Id.

Id (string) - [REQUIRED]

An identifier for a message in this batch is used to communicate the result.

MessageBody (string) - [Required]

The message to send. The minimum size is one character. The maximum size is 256 KB.

DelaySeconds (integer) -

The length of time, in seconds, for which to delay a specific message.

MessageAttributes (dictionary) -

Each message attribute consists of a Name, Type, and Value.

The Name, type, value and message body must not be empty or null.

(string) - The name of the message attributes

(Dictionary) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data, encrypted data, or images.

(string) -[Required] Type of message attributes

EQS support the following data type

Binary, Number, String

MessageSystemAttributes (dictionary) -

Each message system attribute consists of a Name, Type, and Value.

Name, type, value and the message body must not be empty or null.

(string) - The name of the message attributes

(Dictionary) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data,

encrypted data, or images.

(string) - Type of message attributes

EQS support following data type

Binary , Number , String

Response Syntax

{
 "Successful": [
        {
          "Id": "string",
          "MessageId": "string",
          "MD5OfMessageBody": "string",
          "MD5OfMessageAttributes": "string",
          "MD5OfMessageSystemAttributes": "string",
          "SequenceNumber": "string",
        },
  ],
 "Failed": [
        {
          "Id": "string",
          "SenderFault": True | False,
          "Code": "string",
          "Message": "string",
        },
  ],
}
../_images/send_message_batch_boto3.png

Set queue Attributes

Request Syntax

response = eqs_client.set_queue_attributes(
        QueueUrl='string',
        Attributes={
                'string': 'string'
        }
)

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue of which attributes should be set.

Attributes (Dictionary)[Required]

A map of attributes to set.

Response Syntax

None
../_images/tag_queue_boto3.png

Tag queue

Request Syntax

response = eqs_client.tag_queue(
        QueueUrl='string',
        Tags={'string': 'string', }
)

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue.

Tags (Dict) - [Required]

The list of tags to be added to the specified queue.

Response Syntax

None
../_images/tag_queue_boto3.png

Untag queue

Request Syntax

response = eqs_client.untag_queue(
        QueueUrl="string",
        TagKeys=["string", ],
)

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue.

TagKeys (list) - [Required]

The list of tags to be removed from the specified queue.

Response Syntax

None
../_images/untag_queue_boto3.png

Reference code

import boto3


ACCESS_KEY = "your_access_key_id"
SECRET_KEY = "your-secret-key"
SERVICE_NAME = "sqs"
REGION_NAME = "your_region"


class EqsClient:
        # make a connection with the E2E EQS client
        def make_connection(self):
                try:
                        session = boto3.Session()
                        eqs_client = session.client(
                                SERVICE_NAME,
                                aws_access_key_id=ACCESS_KEY,
                                aws_secret_access_key=SECRET_KEY,
                                region_name=REGION_NAME,
                                endpoint_url="your_eqs_endpoint_url",
                        )
                except:
                        print(
                                "problem in making connection with eqs client , please check your credentials"
                        )
                return eqs_client

        # change message visibility timeout of the message
        def change_message_visibility_timeout(
                self, eqs_client, queue_url, receipt_handle, visibility_time
        ):
                try:
                        response = eqs_client.change_message_visibility(
                                QueueUrl=queue_url,
                                ReceiptHandle=receipt_handle,
                                VisibilityTimeout=visibility_time,
                        )
                except:
                        print(" error in changing visibility timeout ")
                return response

        # change message visibility timeout of the messages
        def change_message_visibility_timeout_batch(
                self, eqs_client, queue_url, receipt_handle1, receipt_handle2
        ):
                try:
                        response = eqs_client.change_message_visibility_batch(
                                QueueUrl=queue_url,
                                Entries=[
                                        {
                                                "Id": "1",
                                                "ReceiptHandle": receipt_handle1,
                                                "VisibilityTimeout": 123,
                                        },
                                        {
                                                "Id": "2",
                                                "ReceiptHandle": receipt_handle2,
                                                "VisibilityTimeout": 221,
                                        },
                                ],
                        )
                except:
                        print(" error in changing message visibility in batch ")
                return response

        # close connections with E2E EQS endpoint URL
        def close_connection(self, eqs_client):
                try:
                        return eqs_client.close()
                except:
                        print("error in closing connection with eqs")

        # delete messages
        def delete_message_batch(self, eqs_client, queue_url, rh1, rh2):
                try:
                        response = eqs_client.delete_message_batch(
                                QueueUrl=queue_url,
                                Entries=[
                                        {"Id": "1", "ReceiptHandle": rh1},
                                        {"Id": "2", "ReceiptHandle": rh2},
                                ],
                        )
                except:
                        print("error in deleting messages in batch ")
                return response

        # delete queue
        def delete_queue(self, eqs_client, queue_url):
                try:
                        response = eqs_client.delete_queue(QueueUrl=queue_url)
                except:
                        print("failed to delete queue")
                return response

        # get queue URL
        def get_queue_url(self, eqs_client, queue_name):
                try:
                        response = eqs_client.get_queue_url(QueueName=queue_name)
                except:
                        print(
                                "error in getting url of the queue , please make sure you are using correct queue name"
                        )
                return response

        # list all the queues
        def list_queues(self, eqs_client):
                try:
                        response = eqs_client.list_queues()
                except:
                        print("error in listing queues")
                return response

        # list queue tags based on queue url
        def list_queue_tags(self, eqs_client, queue_url):
                try:
                        response = eqs_client.list_queue_tags(QueueUrl=queue_url)
                except:
                        print(
                                "failed to list queue tags, make sure you are using correct queue url"
                        )
                return response

        # make queue
        def make_queue(self, eqs_client, queue_name):
                try:
                        response = eqs_client.create_queue(QueueName=queue_name)
                except:
                        print("error in making queue")
                return response

        # get attributes of a queue based on queue url
        def get_all_attributes(self, eqs_client, queue_url):
                try:
                        response = eqs_client.get_queue_attributes(
                                QueueUrl=queue_url,
                                AttributeNames=[
                                        "All",
                                ],
                        )

                except:
                        print("error in getting all attributes")
                return response

        # receive a message and delete it from the queue
        def process_messeges(self, eqs_client, queue_url):
                try:
                        response = eqs_client.receive_message(
                                QueueUrl=queue_url,
                                MaxNumberOfMessages=1,
                                VisibilityTimeout=30,
                                WaitTimeSeconds=0,
                        )
                        if "Messages" in response:
                                message = response["Messages"][0]
                                print("Received message: %s" % message["Body"])
                                try:
                                        response = eqs_client.delete_message(
                                                QueueUrl=queue_url, ReceiptHandle=message["ReceiptHandle"]
                                        )
                                except:
                                        print("failed to delete messagae")
                        else:
                                print("No messages in queue")

                except:
                        print("failed to process message")

        # delete all the messages from the queue
        def purge_queue(self, eqs_client, queue_url):
                try:
                        response = eqs_client.purge_queue(QueueUrl=queue_url)
                except:
                        print("failed to delete all messages from queue")
                return response

        # push message to a queue
        def push_message_queue(self, eqs_client, queue_url, message):
                try:
                        response = eqs_client.send_message(QueueUrl=queue_url, MessageBody=message)
                except:
                        print("failed to push message to queue ")
                return response

        # send messages to a queue
        def send_message_batch(self, eqs_client, queue_url):
                try:
                        response = eqs_client.send_message_batch(
                                QueueUrl=queue_url,
                                Entries=[
                                        {
                                                "Id": "1",
                                                "MessageBody": "message1",
                                                "DelaySeconds": 13,
                                                "MessageAttributes": {
                                                        "name1": {
                                                                "StringValue": "string_message",
                                                                "BinaryValue": "bytes_message",
                                                                "DataType": "String",
                                                        }
                                                },
                                                "MessageSystemAttributes": {
                                                        "name_system1": {
                                                                "StringValue": "string_system_message",
                                                                "BinaryValue": b"bytes_system_message",
                                                                "DataType": "String",
                                                        }
                                                },
                                        },
                                        {
                                                "Id": "2",
                                                "MessageBody": "message2",
                                                "DelaySeconds": 12,
                                                "MessageAttributes": {
                                                        "name2": {
                                                                "StringValue": "string_message",
                                                                "BinaryValue": b"bytes_message",
                                                                "DataType": "String",
                                                        }
                                                },
                                                "MessageSystemAttributes": {
                                                        "name_system2": {
                                                                "StringValue": "string_system_message",
                                                                "BinaryValue": b"bytes_system_message",
                                                                "DataType": "String",
                                                        }
                                                },
                                        },
                                ],
                        )
                except:
                        print("error in sending messages")
                return response

        # add tag to a queue
        def tag_queue(self, eqs_client, queue_url, tags):
                try:
                        response = eqs_client.tag_queue(QueueUrl=queue_url, Tags=tags)
                except:
                        print("failed to tag queue")
                return response

        # untag tags form a queue
        def untag_queue(self, eqs_client, queue_url, tagkey):
                try:
                        response = eqs_client.untag_queue(
                                QueueUrl=queue_url,
                                TagKeys=[
                                        tagkey,
                                ],
                        )
                except:
                        print(
                                "falied to untag queue , make sure you are using correct tagkey and queue url"
                        )
                return response

Golang SDK

1 - Install go SDK

To install the SDK and its dependencies, run the following Go command.

go get -u github.com/aws/aws-sdk-go/…

If you set the environment variable to 1, you can use the following command to get the SDK. The SDK’s runtime dependencies are vendored in the vendor/ folder.

go get -u github.com/aws/aws-sdk-go

2 - initialize your folder using (if not already initialized)

go mod init

3 - make connection with the EQS client

To make the connection with the EQS client , you need to pass configurations and credentials.

Configurations-

region_name- your_region
endpoint_url - eqs_endpoint_url (provided by e2e networks eqs service)

Credentials-

aws_access_key_id - your_access_key_id
aws_secret_key_id - your_secret_key_id

Make connection with EQS

There are many ways to provide credentials and configuration to connect with EQS service -

a) providing credentials directly to client object -

warning - Hardcoded credentials in application is not recommended

create a new file named credentials.go .

import (
        "fmt"
        "github.com/aws/aws-sdk-go/aws"
        "github.com/aws/aws-sdk-go/aws/session"
        "github.com/aws/aws-sdk-go/service/sqs"
)

//..

accessKey := "your-access-key"
secretKey := "your-secret-key"
creds := credentials.NewStaticCredentials(accessKey, secretKey, "")
sess , err := session.NewSession(&aws.Config{
                        Region: aws.String("region_name"),
                        Endpoint: aws.String("endpoint_url"),
                        Credentials: creds,
                });

if err != nil {
        fmt.println(“Failed to create session”,err)
        os.Exit(1)
}
eqs_client := sqs.New(sess)

b) you can put credentials and configurations in the config and credentials file , and these files should be located at ~/.aws/config, ~/.aws/credentials location, client will automaticlay access these credentials and configurations.

put in ~/.aws/credentials file

[default]
region = “your_region”

put in ~/.aws/configuration file

[default]
aws_access_key_id = “your access key id”
aws_secret_access_key = “your secret key”

create a new file named credentials.go .

import (
        "fmt"
        "github.com/aws/aws-sdk-go/aws"
        "github.com/aws/aws-sdk-go/aws/session"
        "github.com/aws/aws-sdk-go/service/sqs"
)

//..

sess , err := session.NewSession(&aws.Config{
        Endpoint: aws.String(ENDPOINT),
});

if err != nil {
        fmt.println(“Failed to create session”,err)
        os.Exit(1)
}
eqs_client := sqs.New(sess)

c) you can make the connection with the EQS client by passing the credentials and configuration into the environment variables file.

using terminal (Linux, OS X or Unix)

$ export AWS_ACCESS_KEY_ID = your_access_key_id
$ export AWS_SECRET_ACCESS_KEY = your_secret_key
$ export AWS_DEFAULT_REGION = your_eqs_region

using terminal (Windows)

> set AWS_ACCESS_KEY_ID = your_access_key_id
> set AWS_SECRET_ACCESS_KEY = your_secret_key
> set AWS_DEFAULT_REGION = your_eqs_region

or, edit your enviourment valiable file

AWS_ACCESS_KEY_ID = your_access_key_id
AWS_SECRET_ACCESS_KEY = your_secret_access_key
AWS_DEFAULT_REGION = your_eqs_region

create a new file named credentials.go .

import (
        "fmt"
        "os"
        "github.com/aws/aws-sdk-go/aws"
        "github.com/aws/aws-sdk-go/aws/session"
        "github.com/aws/aws-sdk-go/service/sqs"
        "github.com/joho/godotenv"
)

//..

err := godotenv.Load(".env")
if err != nil {
        fmt.Println("Error loading .env file")
        return
}

accessKey := os.Getenv("AWS_ACCESS_KEY_ID")
secretKey := os.Getenv("AWS_SECRET_ACCESS_KEY")
region := os.Getenv("AWS_REGION")

creds := credentials.NewStaticCredentials(accessKey, secretKey, "")
config := &aws.Config{
        Region:      aws.String(region),
        Endpoint:    aws.String("endpoint_url"),
        Credentials: creds,
}
sess := session.Must(session.NewSession(config))

eqs_client := sqs.New(sess)

Methods available for eqs_client

Change Visibility Timeout

Visibility Timeout refers to the amount of time that a message remains invisible to other consumers after it has been retrieved by a consumer.

Request Syntax

get queue name, receipt handle, visibility timeout

queue := flag.String("q", "your_queue_name", "The name of the queue")
handle := flag.String("h", "message_receipt_handle", "The receipt handle of the message")
visibility := flag.Int64("v", 50, "The duration, in seconds, that the message is not visible to other consumers")
flag.Parse()

if *queue == "" || *handle == "" {
        fmt.Println("You must supply a queue name (-q QUEUE) and message receipt handle (-h
        HANDLE)")
        return
}
if *visibility < 0 {
        *visibility = 0
}
if *visibility > 12*60*60 {
        *visibility = 12 * 60 * 60
}

get queue url using eqs_client

result, err := eqs_client.GetQueueUrl(&sqs.GetQueueUrlInput{
                QueueName: queue,
})
queueURL := urlResult.QueueUrl

calling ChangeMessageVisibility method using eqs_client

_, err := eqs_client.ChangeMessageVisibility(&sqs.ChangeMessageVisibilityInput{
        ReceiptHandle: handle,
        QueueUrl: queueURL,
        VisibilityTimeout: visibility,
})

Parameters

QueueUrl (string)- [Required]

The URL of the E2E EQS queue whose message’s visibility is changed.

ReceiptHandle (string) - [Required]

The receipt handle is associated with the message whose visibility timeout is changed. This parameter is returned by the ReceiveMessage action

VisibilityTimeout (integer) - [Required]

The new value for the message’s visibility timeout (in seconds)

Valid values - 0 to 43,200 seconds (12 hours)

default - 30 second

Response Syntax

nil

Create Queue

Request Syntax

get queue name

queue := flag.String("q", "your_queue_name", "The name of the queue")
flag.Parse()

if *queue == "" {
        fmt.Println("You must supply a queue name (-q QUEUE")
        return
}

Use CreateQueue method using eqs_client to create a queue using queue name, You can also define attributes and tags for the queue

result, err := eqs_client.CreateQueue(&sqs.CreateQueueInput{
QueueName: queue,
Attributes: map[string]*string{
        "DelaySeconds": aws.String("60"),
        "MessageRetentionPeriod": aws.String("86400"),
},
Tags: map[string]*string{
        "Environment": aws.String("Production"),
        "Application": aws.String("MyApp"),
},
})

take queue url from result

fmt.Println("URL: " + *result.QueueUrl)

Parameters

QueueName (string)- [Required]

1 - A queue name can have up to 80 characters

2 - Valid values: alphanumeric characters, hyphens ( -), and underscores ( _).

Attributes (map)- Attributes could be

1 - DelaySeconds - Time(second), to which extent delivery of messages is delayed in the queue

Valid values - 0 to 900 (second)

default - 0 (second)

2 - MaximumMessageSize - The size of the message after which the queue will reject the message

Valid values - 1,024 bytes (1 KiB) to 262,144 bytes (256 KiB)

default - 262,144 bytes(256 KiB)

3 - MessageRetentionPeriod - Time to which extent a queue will retain a message

Valid values - 60 seconds (1 minute) to 1,209,600 seconds (14 days)

default - 345,600 (4 days)

4 - ReceiveMessageWaitTimeSeconds - Time to which extent ReceiveMessage action waits before receiving a message

Valid values - 0 to 20 (seconds)

default - 0 (second)

5 - VisibilityTimeout - The amount of time that a message in a queue is invisible to other consumers after a consumer retrieves it.

Valid values - 0 to 43,200 seconds (12 hours)

default - 30 second

tags (map) -

1 - Adding more than 50 tags to a queue isn’t recommended.

2 - A new tag with a key identical to that of an existing tag overwrites the existing tag.

Response Syntax (result)

{ QueueUrl: "queue_url"}

Delete message

Request Syntax

get the queue name and message handle

queue := flag.String("q", "", "The name of the queue")
messageHandle := flag.String("m", "", "The receipt handle of the message")
flag.Parse()

if *queue == "" || *messageHandle == "" {
        fmt.Println("You must supply a queue name (-q QUEUE) and message receipt handle (-m
        MESSAGE-HANDLE)")
        return
}

pass queue url and message handle and call DeleteMessage method using client

_, err := eqs_client.DeleteMessage(&sqs.DeleteMessageInput{
        QueueUrl: queueURL,
        ReceiptHandle: messageHandle,
})

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which messages are deleted.

ReceiptHandle (string) - [Required]

The receipt handle is associated with the message to delete.

Response Syntax

nil

Delete message in batch

Request Syntax

prepare the input for DeleteMessageBatch API call

input = &sqs.DeleteMessageBatchInput{QueueUrl: aws.String(queueURL), }

for i, receiptHandle := range messageReceiptHandles {
        input.Entries = append(input.Entries, &sqs.DeleteMessageBatchRequestEntry{
                Id:            aws.Stirng(strconv.Itoa(i)),
                ReceiptHandle: receiptHandle,
        })
}

call the DeleteMessageBatch method using eqs_client

_, err = eqs_client.DeleteMessageBatch(input)

if err!= nil {
        return err
}

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which messages are deleted.

Entries (slice) - [Required]

(map) id [Required]-(string) An identifier for this particular receipt handle used to communicate the result ReceiptHandle [Required] -(string) A receipt handle

Response Syntax

{
  "Successful": [{"Id": "string"}, ],
  "Failed": [
  {
          "Id": "string",
          "SenderFault": True | False,
          "Code": "string",
          "Message": "string",
  },
  ],
}

Delete queue

Request Syntax

getting the queue url*

queueURL := "your-queue-url"

calling the DeleteQueue method using eqs_client

_, err := eqs_client.DeleteQueue(&sqs.DeleteQueueInput{
        QueueUrl: aws.String(queueURL),
})
if err != nil {
        // handle error
}

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue to delete.

Response Syntax

nil

Get queue attributes

Request Syntax

calling GetQueueAttributes method using eqs_client

result, err := eqs_client.GetQueueAttributes(&sqs.GetQueueAttributesInput{
        QueueUrl: aws.String("queue-url"),
        AttributeNames: []*string{
                aws.String(sqs.QueueAttributeNameAll),
        },
})

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which attributes are get.

AttributeNames (slice) - [Optional]

A list of attributes for which to retrieve information

All - it specifies, returns all values

you can also specify specific attributes in the list

As - [‘VisibilityTimeout’ , ‘MaximumMessageSize’ , ‘MessageRetentionPeriod’ , ‘ApproximateNumberOfMessages’ ,’ApproximateNumberOfMessagesNotVisible’ , ‘CreatedTimestamp’ , ‘LastModifiedTimestamp’ , ‘QueueArn’ , ‘ApproximateNumberOfMessagesDelayed’ , ‘DelaySeconds’ , ‘ReceiveMessageWaitTimeSeconds’]

Response Syntax

{
   Attributes: map[string]*string{
       "VisibilityTimeout": aws.String("60"),
   },
}

Get queue url

Request Syntax

getting input using queue name

input := &sqs.GetQueueUrlInput{
        QueueName: aws.String("my_queue_name"),
}

calling GetQueueUrl method using eqs_client passing input as params

result, err := eqs_client.GetQueueUrl(input)

if err != nil {
        fmt.println("Error in getting queue", err)
        return
}

fmt.Println("Queue URL:", *result.QueueUrl)

Parameters

QueueName (string) -[Required]

The name of the queue whose URL must be fetched.

Response Syntax

{ QueueUrl: string, }

List queue tags

Request Syntax

defining input using queue url

input := &sqs.ListQueueTagsInput{
    QueueUrl: aws.String(queueUrl),
}

calling ListQueueTags method using eqs_client

resp, err := eqs_client.ListQueueTags(input)
if err != nil {
    fmt.Println("Error listing queue tags:", err)
    return
}

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue of which all the tags must be listed.

Response Syntax

type ListQueueTagsOutput struct {
        Tags map[string]*string `type:"map" required:"true"`
}

List queues

Request Syntax

Set the queue name prefix and max results to retrieve

queueNamePrefix := "my-queue"
maxResults := int64(10)

Call the ListQueues API with the specified parameters

resp, err := svc.ListQueues(&sqs.ListQueuesInput{
    QueueNamePrefix: &queueNamePrefix,
    MaxResults: &maxResults,
})

if err != nil {
    fmt.Println("Error listing queues:", err)
    return
}

Print out the URLs of the returned queues

for _, url := range resp.QueueUrls {
    fmt.Println(*url)
}
Parameters
QueueNamePrefix (string) - [Optional]

A string to use for filtering the list results. Only those queues whose name begins with the specified string are returned.

MaxResults (integer) - [Optional]

The maximum number of results to include in the response. Valid values - 1 to 1000

Response Syntax (resp)

type ListQueuesOutput struct {
        QueueUrls []*string `type:"list" required:"true"`
}

Purge queue

delete all the messages from queue.

Request Syntax

calling PurgeQueue method using eqs_client

_, err := eqs_client.PurgeQueue(&sqs.PurgeQueueInput{
        QueueUrl: queueURL,
})

if err != nil {
        fmt.Println("Error purging queue:", err)
        return
}

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue of which all the messages must be deleted.

Response Syntax

nil

Receive Message

Request Syntax getting queue url, visibility timeout, AttributeNames, MessageAttributeNames, maxNumberOfMessages and waitTimeSeconds

queueURL := "YOUR_QUEUE_URL"
attributeNames := []*string{
        aws.String("All"), // returns all attributes
}
messageAttributeNames := []*string{
        aws.String("ATTRIBUTE_NAME"),
}
maxNumberOfMessages := aws.Int64(2)
visibilityTimeout := aws.Int64(25)
waitTimeSeconds := aws.Int64(10)

calling ReceiveMessage method using eqs_client

result, err := eqs_client.ReceiveMessage(&sqs.ReceiveMessageInput{
        AttributeNames:        attributeNames,
        MessageAttributeNames: messageAttributeNames,
        MaxNumberOfMessages:   maxNumberOfMessages,
        QueueUrl:              &queueURL,
        VisibilityTimeout:     visibilityTimeout,
        WaitTimeSeconds:       waitTimeSeconds,
})

if err != nil {
        fmt.Println("Error receiving messages:", err)
        return
}

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which messages are received.

AttributeNames (slice) -

A list of attributes that need to be returned along with each message.

All - it specifies, returns all values

you can also specify specific attributes in the list

As - [‘VisibilityTimeout’ , ‘MaximumMessageSize’ , ‘MessageRetentionPeriod’ , ‘ApproximateNumberOfMessages’ ,’ApproximateNumberOfMessagesNotVisible’ , ‘CreatedTimestamp’ , ‘LastModifiedTimestamp’ , ‘QueueArn’ , ‘ApproximateNumberOfMessagesDelayed’ , ‘DelaySeconds’ , ‘ReceiveMessageWaitTimeSeconds’]

MessageAttributeNames (slice) -

The name of the message attribute.

MaxNumberOfMessages (integer) -

The maximum number of messages to return.

Valid range - 1 to 10

default - 1

VisibilityTimeout (integer) -

The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request.

WaitTimeSeconds (integer) -

The duration (in seconds) for which the call waits for a message to arrive in the queue before returning.

Response Syntax

type ReceiveMessageOutput struct {
Messages []*Message // a list of received messages
}

type Message struct {
        MessageId            *string
        ReceiptHandle        *string
        MD5OfBody            *string
        Body                 *string
        MD5OfMessageAttributes *string
        Attributes           map[string]*string // message system attributes
        MessageAttributes    map[string]*MessageAttributeValue // message user-defined attributes
}

type MessageAttributeValue struct {
        StringValue *string // string value of the message attribute
        BinaryValue []byte // binary value of the message attribute
        DataType    *string // data type of the message attribute
}

Send messgage

Request Syntax setting up params

params := &sqs.SendMessageInput{
QueueUrl: aws.String("QUEUE_URL_HERE"),
MessageBody: aws.String("MESSAGE_BODY_HERE"),
DelaySeconds: aws.Int64(123),
MessageAttributes: map[string]*sqs.MessageAttributeValue{
    "ATTRIBUTE_NAME_HERE": {
        DataType: aws.String("STRING"),
        StringValue: aws.String("ATTRIBUTE_VALUE_HERE"),
    },
},
MessageSystemAttributes: map[string]*sqs.MessageSystemAttributeValue{
    "SYSTEM_ATTRIBUTE_NAME_HERE": {
        DataType: aws.String("STRING"),
        StringValue: aws.String("SYSTEM_ATTRIBUTE_VALUE_HERE"),
    },
},
    }

calling SendMesssage method using eqs_client

resp, err := eqs_client.SendMessage(params)
if err != nil {
        // handle error
        return
}

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue to which messages are send.

MessageBody (string) - [Required]

The message to send. The minimum size is one character. The maximum size is 256 KB.

DelaySeconds (integer) -

The length of time, in seconds, for which to delay a specific message.

MessageAttributes (map) -

Each message attribute consists of a Name, Type, and Value .

Name, type, value and the message body must not be empty or null .

(string) - name of the message attributes

(map) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data, encrypted data, or images.

(string) - [Required] Type of message attributes

EQS support the following data type

Binary, Number, String

MessageSystemAttributes (map) -

Each message system attribute consists of a Name, Type, and Value.

The name, type, value and message body must not be empty or null.

(string) - the name of the message attributes

(map) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data, encrypted data, or images.

(string) - Type of message attributes

EQS support the following data type

Binary , Number , String

Response Syntax

resp := &sqs.SendMessageOutput{
        MD5OfMessageBody:           aws.String("hash_of_message_body"),
        MD5OfMessageAttributes:     aws.String("hash_of_message_attribute"),
        MD5OfMessageSystemAttributes: aws.String("hash_of_message_system_attributes"),
        MessageId:                  aws.String("message_id"),
        SequenceNumber:             aws.String("sequence_number"),
}

Send message in batch

Request Syntax calling SendMessageBatch method using eqs_client

resp, err := eqs_client.SendMessageBatch(&sqs.SendMessageBatchInput{
QueueUrl: aws.String("QUEUE_URL"),
Entries: []*sqs.SendMessageBatchRequestEntry{
    {
        Id:           aws.String("MESSAGE_ID_1"),
        MessageBody:  aws.String("MESSAGE_BODY_1"),
        DelaySeconds: aws.Int64(0),
        MessageAttributes: map[string]*sqs.MessageAttributeValue{
            "ATTRIBUTE_NAME_1": &sqs.MessageAttributeValue{
                DataType:    aws.String("STRING"),
                StringValue: aws.String("ATTRIBUTE_VALUE_1"),
            },
            "ATTRIBUTE_NAME_2": &sqs.MessageAttributeValue{
                DataType:    aws.String("NUMBER"),
                StringValue: aws.String("ATTRIBUTE_VALUE_2"),
            },
        },
        MessageSystemAttributes: map[string]*sqs.MessageSystemAttributeValue{
            "SYSTEM_ATTRIBUTE_NAME_1": &sqs.MessageSystemAttributeValue{
                DataType:    aws.String("STRING"),
                StringValue: aws.String("SYSTEM_ATTRIBUTE_VALUE_1"),
            },
            "SYSTEM_ATTRIBUTE_NAME_2": &sqs.MessageSystemAttributeValue{
                DataType:    aws.String("BINARY"),
                BinaryValue: []byte("SYSTEM_ATTRIBUTE_VALUE_2"),
            },
        },
    },
    {
        Id:           aws.String("MESSAGE_ID_2"),
        MessageBody:  aws.String("MESSAGE_BODY_2"),
        DelaySeconds: aws.Int64(0),
        MessageAttributes: map[string]*sqs.MessageAttributeValue{
            "ATTRIBUTE_NAME_3": &sqs.MessageAttributeValue{
                DataType:    aws.String("STRING"),
                StringValue: aws.String("ATTRIBUTE_VALUE_3"),
            },
            "ATTRIBUTE_NAME_4": &sqs.MessageAttributeValue{
                DataType:    aws.String("NUMBER"),
                StringValue: aws.String("ATTRIBUTE_VALUE_4"),
            },
        },
        MessageSystemAttributes: map[string]*sqs.MessageSystemAttributeValue{
            "SYSTEM_ATTRIBUTE_NAME_3": &sqs.MessageSystemAttributeValue{
                DataType:    aws.String("STRING"),
                StringValue: aws.String("SYSTEM_ATTRIBUTE_VALUE_3"),
            },
            "SYSTEM_ATTRIBUTE_NAME_4": &sqs.MessageSystemAttributeValue{
                DataType:    aws.String("BINARY"),
                BinaryValue: []byte("SYSTEM_ATTRIBUTE_VALUE_4"),
            },
        },
    },
},
    })

    if err != nil {
            fmt.Println("Error", err)
            return
    }

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue to which messages are sent.

Entries (slice) - [Required]

A list of SendMessageBatchRequestEntry items.

(Dict) -

Contains the details of a single E2E EQS message along with an Id.

Id (string) - [REQUIRED]

An identifier for a message in this batch is used to communicate the result.

MessageBody (string) - [Required]

The message to send. The minimum size is one character. The maximum size is 256 KB.

DelaySeconds (integer) -

The length of time, in seconds, for which to delay a specific message.

MessageAttributes (map) -

Each message attribute consists of a Name, Type, and Value.

The Name, type, value and message body must not be empty or null.

(string) - The name of the message attributes

(map) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data, encrypted data, or images.

(string) -[Required] Type of message attributes

EQS support the following data type

Binary, Number, String

MessageSystemAttributes (map) -

Each message system attribute consists of a Name, Type, and Value.

Name, type, value and the message body must not be empty or null.

(string) - The name of the message attributes

(map) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data,

encrypted data, or images.

(string) - Type of message attributes

EQS support following data type

Binary , Number , String

Response Syntax

type SendMessageBatchOutput struct {
        Successful []SendMessageBatchResultEntry   `locationNameList:"SendMessageBatchResultEntry"  type:"list"`
        Failed     []BatchResultErrorEntry         `locationNameList:"BatchResultErrorEntry"        type:"list"`
}

type SendMessageBatchResultEntry struct {
        Id                         *string                              `type:"string"`
        MessageId                  *string                              `type:"string"`
        MD5OfMessageAttributes     *string                              `type:"string"`
        MD5OfMessageBody           *string                              `type:"string"`
        MD5OfMessageSystemAttributes *string                            `type:"string"`
        SequenceNumber             *string                               `type:"string"`
}

type BatchResultErrorEntry struct {
        Id             *string                  `type:"string"`
        SenderFault    *bool                            `type:"boolean"`
        Code           *string                          `type:"string"`
        Message        *string                          `type:"string"`
}

Set queue Attributes

Request Syntax

calling SetQueueAttributes method using eqs_client

_, err := eqs_client.SetQueueAttributes(&sqs.SetQueueAttributesInput{
        QueueUrl: aws.String("YOUR_QUEUE_URL_HERE"),
        Attributes: map[string]*string{
                "Attribute1": aws.String("Value1"),
                "Attribute2": aws.String("Value2"),
                // Add more attributes here as needed.
        },
})

if err != nil {
        // Handle error.
        panic(err)
}

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue of which attributes should be set.

Attributes (map)[Required]

A map of attributes to set.

Response Syntax

nil

Tag queue

Request Syntax

calling TagQueue method using eqs_client

resp, err := svc.TagQueue(&sqs.TagQueueInput{
QueueUrl: aws.String("YOUR_QUEUE_URL_HERE"),
Tags: map[string]*string{
    "Tag1": aws.String("Value1"),
    "Tag2": aws.String("Value2"),
    // Add more tags here as needed.
},
    })

    if err != nil {
            // Handle error.
            panic(err)
    }

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue.

Tags (map) - [Required]

The list of tags to be added to the specified queue.

Response Syntax

nil

Untag Queue

Request Syntax

set queue url and tags

queueURL := "your_queue_url"
tags := map[string]*string{
    "Environment": aws.String("production"),
    "Owner":       aws.String("[email protected]"),
}

set input params

params := &sqs.TagQueueInput{
            QueueUrl: &queueURL,
            Tags:     tags,
}

calling UntagQueue method using eqs_client

_, err := svc.TagQueue(params)
if err != nil {
    fmt.Println("Error setting tags:", err)
    return
}

fmt.Println("Tags successfully set!")

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue.

TagKeys (slice) - [Required]

The list of tags to be removed from the specified queue.

Response Syntax

nil

Nodejs SDK

1 - install sdk package in to your directory (make sure that Node.js is install in your machine)

npm install @aws-sdk

You can install specific package which is required , like right now we are working on SQS so we can install SQS.

npm install @aws-sdk/client-sqs

2 - Make a connection with the EQS client.

To make the connection with the EQS client , you need to pass configurations and credentials.

Configurations-

region_name = your_region
endpoint_url = eqs_endpoint_url (provided by e2e networks eqs service)

Credentials-

aws_access_key_id = your_access_key_id
aws_secret_key_id = your_secret_key_id

Make Connection with EQS

there are many ways to make connection with eqs_client

a) You can directly pass the credentials and configurations at the time of making a session with the EQS client. warning - Hardcoded credentials in application is not recommended

create a new file named index.js

import {SQSClient} from “@aws-sdk/client-sqs”

REGION          = “your_region”
ENDPOINT        = “endpoint_provided_by_E2E“
ACCESSKEYID     = “access_key_id“
SECRETACCESSKEY = “your_secret_access_key“

const  eqs_client = new SQSClient( {
        region : REGION,
        endpoint : ENDPOINT,
        credentials : {
                accessKeyId : ACCESSKEYID,
                secretAccessKey : SECRETACCESSKEY
                }
    });

b) you can put credentials and configurations in the config and credentials file , and these files should be located at ~/.aws/config, ~/.aws/credentials location.

put credentials into ~/.aws/credentials file

[default]
aws_access_key_id=”access_key_id”
aws_secret_access_key=”secret_key “

put config into ~/.aws/config file

[default]
region =”region“

create a new file named index.js

import {SQSClient} from “@aws-sdk/client-sqs”

ENDPOINT = “eqs_endpoint_url_provided_by_e2e“

const  eqs_client = new SQSClient( { endpoint : ENDPOINT  });

c) you can make the connection with the EQS client by passing the credentials and configuration into the environment variables file.

install dotenv

npm install dotenv

using terminal (Linux, OS X or Unix)

$ export AWS_ACCESS_KEY_ID = your_access_key_id
$ export AWS_SECRET_ACCESS_KEY = your_secret_key
$ export AWS_DEFAULT_REGION = your_eqs_region
$ export ENDPOINT = end_point_url

using terminal (Windows)

> set AWS_ACCESS_KEY_ID = your_access_key_id
> set AWS_SECRET_ACCESS_KEY = your_secret_key
> set AWS_DEFAULT_REGION = your_eqs_region
> set ENDPOINT = end_point_url

or, edit your enviourment valiable file

AWS_ACCESS_KEY_ID = your_access_key_id
AWS_SECRET_ACCESS_KEY = your_secret_access_key
AWS_DEFAULT_REGION = your_eqs_region
ENDPOINT = end_point_url

create a file named index.js

import { SQSClient } from '@aws-sdk/client-sqs';

import dotenv from 'dotenv';
dotenv.config();

const eqs_client = new SQSClient({
        region: process.env.AWS_REGION,
        credentials: {
                accessKeyId: process.env.AWS_ACCESS_KEY_ID,
                secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
        },
        endpoint: process.env.ENDPOINT,
});

export { eqs_client };

Methods available for eqs_client

Change VisibilityTimeout

Request Syntax

import { SQS } from 'aws-sdk';
const eqs_client = new SQS();

const queueUrl = 'YOUR_QUEUE_URL';
const receiptHandle = 'YOUR_RECEIPT_HANDLE';
const visibilityTimeout = 123;

const params = {
    QueueUrl: queueUrl,
    ReceiptHandle: receiptHandle,
    VisibilityTimeout: visibilityTimeout
    };

eqs_client.changeMessageVisibility(params, function(err, data) {
    if (err) {
        console.log("Error", err);
    } else {
        console.log("Success", data);
    }
});

Parameters

QueueUrl (string)- [Required]

The URL of the E2E EQS queue whose message’s visibility is changed.

ReceiptHandle (string) - [Required]

The receipt handle is associated with the message whose visibility timeout is changed. This parameter is returned by the ReceiveMessage action

VisibilityTimeout (integer) - [Required]

The new value for the message’s visibility timeout (in seconds)

Response Syntax

None

Change VisibilityTimeout batch

Request Syntax

import { SQS } from 'aws-sdk';
const eqs_client = new SQS();

const queueUrl = 'YOUR_QUEUE_URL';
const entries = [
 {
        Id: 'MESSAGE_ID_1',
        ReceiptHandle: 'RECEIPT_HANDLE_1',
        VisibilityTimeout: 123
 },
 {
        Id: 'MESSAGE_ID_2',
        ReceiptHandle: 'RECEIPT_HANDLE_2',
        VisibilityTimeout: 456
 }
];

const params = {
        QueueUrl: queueUrl,
        Entries: entries
};

eqs_client.changeMessageVisibilityBatch(params, function(err, data) {
   if (err) {
          console.log("Error", err);
   } else {
          console.log("Success", data.Successful);
          console.log("Failures", data.Failed);
   }
});

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue whose message’s visibility is changed.

Entries (Array) - [Required]

(map)

id [Required]-(string) An identifier for this particular receipt handle used to communicate the result

ReceiptHandle [Required] -(string) A receipt handle

VisibilityTimeout - (string) The new value (in seconds) for the message’s visibility timeout

Response Syntax

{
  Successful: [
        {
          Id: 'string'
        },
  ],
  Failed: [
        {
          Id: 'string',
          SenderFault: true | false,
          Code: 'string',
          Message: 'string'
        },
  ]
}

Close connection

Request Syntax

import { SQS } from 'aws-sdk';
const eqs_client = new SQS();

eqs_client.close(function(err) {
if (err) {
   console.error('Error closing the connection: ', err);
} else {
   console.log('Connection closed successfully.');
}
});

Response Syntax

None

Create Queue

Request Syntax

import { SQS } from 'aws-sdk';
const eqs_client = new SQS();

const params = {
QueueName: 'QUEUE_NAME',
Attributes: {
   'DelaySeconds': '0',
   'MaximumMessageSize': '262144',
   'MessageRetentionPeriod': '345600',
   'ReceiveMessageWaitTimeSeconds': '0',
   'VisibilityTimeout': '30'
},
tags: {
   'Tag1': 'Value1',
   'Tag2': 'Value2'
}
};

eqs_client.createQueue(params, function(err, data) {
if (err) {
   console.log('Error creating queue: ', err);
} else {
   console.log('Queue URL: ', data.QueueUrl);
}
});

Parameters

QueueName (string)- [Required]

1 - A queue name can have up to 80 characters

2 - Valid values: alphanumeric characters, hyphens ( -), and underscores ( _).

Attributes (map)- Attributes could be

1 - DelaySeconds - Time(second), to which extent delivery of messages is delayed in the queue

Valid values - 0 to 900 (second)

default - 0 (second)

2 - MaximumMessageSize - The size of the message after which the queue will reject the message

Valid values - 1,024 bytes (1 KiB) to 262,144 bytes (256 KiB)

default - 262,144 bytes(256 KiB)

3 - MessageRetentionPeriod - Time to which extent a queue will retain a message

Valid values - 60 seconds (1 minute) to 1,209,600 seconds (14 days)

default - 345,600 (4 days)

4 - ReceiveMessageWaitTimeSeconds - Time to which extent ReceiveMessage action waits before receiving a message

Valid values - 0 to 20 (seconds)

default - 0 (second)

5 - VisibilityTimeout - The amount of time that a message in a queue is invisible to other consumers after a consumer retrieves it.

Valid values - 0 to 43,200 seconds (12 hours)

default - 30 second

tags (map) -

1 - Adding more than 50 tags to a queue isn’t recommended.

2 - A new tag with a key identical to that of an existing tag overwrites the existing tag.

Response Syntax

{ QueueUrl: 'string' }

Delete message

Request Syntax

import { SQS } from 'aws-sdk';
const eqs_client = new SQS();

eqsClient.deleteMessage({
   QueueUrl: 'string',
   ReceiptHandle: 'string'
}, function(err, data) {
   if (err) {
          console.log("Error", err);
   } else {
          console.log("Message Deleted", data);
   }
});

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which messages are deleted.

ReceiptHandle (string) - [Required]

The receipt handle is associated with the message to delete.

Response Syntax

None

Delete message in batch

Request Syntax

import { SQS } from 'aws-sdk';
const eqs_client = new SQS();

const params = {
QueueUrl: 'STRING_VALUE',
Entries: [
   {
         Id: 'STRING_VALUE',
         ReceiptHandle: 'STRING_VALUE'
   },
],
};

sqs.deleteMessageBatch(params, function(err, data) {
   if (err) console.log(err, err.stack);
   else console.log(data);
});

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which messages are deleted.

Entries (Array) - [Required]

(map) id [Required]-(string) An identifier for this particular receipt handle used to communicate the result ReceiptHandle [Required] -(string) A receipt handle

Response Syntax

{
  "Successful": [
        {
          "Id": "string"
        }
  ],
  "Failed": [
        {
          "Id": "string",
          "SenderFault": true|false,
          "Code": "string",
          "Message": "string"
        }
  ]
}

Delete queue

Request Syntax

var params = {
        QueueUrl: 'STRING_VALUE' /* required */
};
eqs_client.deleteQueue(params, function(err, data) {
        if (err) console.log(err, err.stack); // an error occurred
        else     console.log(data);           // successful response
});

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue to delete.

Response Syntax

None

Get Queue Attributes

Request Syntax

import { SQS } from 'aws-sdk';
const eqs_client = new SQS();

const params = {
   QueueUrl: 'QUEUE_URL',
   AttributeNames: [
          'All'
   ]
};

eqs_client.getQueueAttributes(params, (err, data) => {
   if (err) {
          console.log('Error', err);
   } else {
          console.log('Success', data.Attributes);
   }
});

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which attributes are get.

AttributeNames (Array) - [Optional]

A list of attributes for which to retrieve information

All - it specifies, returns all values

you can also specify specific attributes in the list

As - [‘VisibilityTimeout’ , ‘MaximumMessageSize’ , ‘MessageRetentionPeriod’ , ‘ApproximateNumberOfMessages’ ,’ApproximateNumberOfMessagesNotVisible’ , ‘CreatedTimestamp’ , ‘LastModifiedTimestamp’ , ‘QueueArn’ , ‘ApproximateNumberOfMessagesDelayed’ , ‘DelaySeconds’ , ‘ReceiveMessageWaitTimeSeconds’]

Response Syntax

{
   Attributes: {
          string: string
   }
}

Get queue url

Request Syntax

import { SQS } from 'aws-sdk';
const eqs_client = new SQS();

var params = {
   QueueName: 'STRING_VALUE'
};

eqs_client.getQueueUrl(params, function(err, data) {
   if (err) console.log(err, err.stack);
   else   console.log(data);
});

Parameters

QueueName (string) -[Required]

The name of the queue whose URL must be fetched.

Response Syntax

{ QueueUrl: 'STRING_VALUE' }

List queue tags

Request Syntax

import { SQS } from 'aws-sdk';
const eqs_client = new SQS();

var params = {
   QueueUrl: 'STRING_VALUE'
};

eqs_client.listQueueTags(params, function(err, data) {
   if (err) console.log(err, err.stack);
   else   console.log(data);
});

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue of which all the tags must be listed.

Response Syntax

{
   Tags: {
         'STRING_VALUE': 'STRING_VALUE',
    }
}

List queues

Request Syntax

import { SQS } from 'aws-sdk';
const eqs_client = new SQS();

var params = {
  QueueNamePrefix: 'STRING_VALUE',
  MaxResults: 123
};

sqs.listQueues(params, function(err, data) {
   if (err) console.log(err, err.stack);
   else   console.log(data);
});
Parameters
QueueNamePrefix (string) - [Optional]

A string to use for filtering the list results. Only those queues whose name begins with the specified string are returned.

MaxResults (integer) - [Optional]

The maximum number of results to include in the response. Valid values - 1 to 1000

Response Syntax

{
   QueueUrls: [
          'STRING_VALUE',
   ]
}

Receive message

Request Syntax

import { SQS } from 'aws-sdk';
const eqs_client = new SQS();
var params = {
            QueueUrl: 'STRING_VALUE',
            AttributeNames: [
                    'All',
            ],
            MessageAttributeNames: [
                    'STRING_VALUE',
            ],
            MaxNumberOfMessages: 2,
            VisibilityTimeout: 25,
            WaitTimeSeconds: 10,
            ReceiveRequestAttemptId: 'STRING_VALUE'
    };

eqs_client.receiveMessage(params, function(err, data) {
            if (err) console.log(err, err.stack);
            else     console.log(data);
    });

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which messages are received.

AttributeNames (Array) -

A list of attributes that need to be returned along with each message.

All - it specifies, returns all values

you can also specify specific attributes in the list

As - [‘VisibilityTimeout’ , ‘MaximumMessageSize’ , ‘MessageRetentionPeriod’ , ‘ApproximateNumberOfMessages’ ,’ApproximateNumberOfMessagesNotVisible’ , ‘CreatedTimestamp’ , ‘LastModifiedTimestamp’ , ‘QueueArn’ , ‘ApproximateNumberOfMessagesDelayed’ , ‘DelaySeconds’ , ‘ReceiveMessageWaitTimeSeconds’]

MessageAttributeNames (Array) -

The name of the message attribute.

MaxNumberOfMessages (integer) -

The maximum number of messages to return.

Valid range - 1 to 10

default - 1

VisibilityTimeout (integer) -

The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request.

WaitTimeSeconds (integer) -

The duration (in seconds) for which the call waits for a message to arrive in the queue before returning.

Response Syntax

{
   Messages: [
          {
                MessageId: 'STRING_VALUE',
                ReceiptHandle: 'STRING_VALUE',
                MD5OfBody: 'STRING_VALUE',
                Body: 'STRING_VALUE',
                Attributes: {
                        'STRING_VALUE': 'STRING_VALUE'
                },
                MD5OfMessageAttributes: 'STRING_VALUE',
                MessageAttributes: {
                        'STRING_VALUE': {
                        StringValue: 'STRING_VALUE',
                        BinaryValue: 'BYTES_VALUE',
                        DataType: 'STRING_VALUE'
                        }
                }
          }
   ]
}

Send messgage

Request Syntax

import { SQS } from 'aws-sdk';
const eqs_client = new SQS();
var params = {
        QueueUrl: 'STRING_VALUE', /* required */
        MessageBody: 'STRING_VALUE',
        DelaySeconds: 0,
        MessageAttributes: {
            'STRING_VALUE': {
                DataType: 'STRING_VALUE',
                BinaryValue: Buffer.from('...') || 'STRING_VALUE',
                StringValue: 'STRING_VALUE'
                },
        },
        MessageSystemAttributes: {
                'STRING_VALUE': {
                DataType: 'STRING_VALUE',
                BinaryValue: Buffer.from('...') || 'STRING_VALUE',
                StringValue: 'STRING_VALUE'
                },
        }
};

eqs_client.sendMessage(params, function(err, data) {
        if (err) console.log(err, err.stack);
        else     console.log(data);
});

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue to which messages are send.

MessageBody (string) - [Required]

The message to send. The minimum size is one character. The maximum size is 256 KB.

DelaySeconds (integer) -

The length of time, in seconds, for which to delay a specific message.

MessageAttributes (map) -

Each message attribute consists of a Name, Type, and Value .

Name, type, value and the message body must not be empty or null .

(string) - name of the message attributes

(map) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data,

encrypted data, or images.

(string) - [Required] Type of message attributes

EQS support the following data type

Binary, Number, String

MessageSystemAttributes (dictionary) -

Each message system attribute consists of a Name, Type, and Value.

The name, type, value and message body must not be empty or null.

(string) - the name of the message attributes

(dictionary) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data,

encrypted data, or images.

(string) - Type of message attributes

EQS support the following data type

Binary , Number , String

Response Syntax

{
   'MD5OfMessageBody': 'string',
   'MD5OfMessageAttributes': 'string',
   'MD5OfMessageSystemAttributes': 'string',
   'MessageId': 'string',
   'SequenceNumber': 'string'
}

Send message in batch

Request Syntax

import { SQS } from 'aws-sdk';
const eqs_client = new SQS();
var params = {
   QueueUrl: "STRING_VALUE", // the URL of the E2E EQS queue
   Entries: [
          {
                Id: "MESSAGE_ID", // an identifier for the message in the batch
                MessageBody: "MESSAGE_BODY", // the message to send
                DelaySeconds: 0, // the number of seconds to delay the message (optional)
                MessageAttributes: {
                   "ATTRIBUTE_NAME": {
                   DataType: "STRING_VALUE",
                   StringValue: "STRING_VALUE",
                   BinaryValue: new Buffer("BYTES_VALUE")
                        }
                },
                MessageSystemAttributes: {
                   "ATTRIBUTE_NAME": {
                   DataType: "STRING_VALUE",
                   StringValue: "STRING_VALUE",
                   BinaryValue: new Buffer("BYTES_VALUE")
                        }
                }
          }
   ]
};

eqs_client.sendMessageBatch(params, function(err, data) {
   if (err) console.log(err, err.stack);
   else console.log(data);
});

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue to which messages are sent.

Entries (Array) - [Required]

A list of SendMessageBatchRequestEntry items.

(map) -

Contains the details of a single E2E EQS message along with an Id.

Id (string) - [REQUIRED]

An identifier for a message in this batch is used to communicate the result.

MessageBody (string) - [Required]

The message to send. The minimum size is one character. The maximum size is 256 KB.

DelaySeconds (integer) -

The length of time, in seconds, for which to delay a specific message.

MessageAttributes (map) -

Each message attribute consists of a Name, Type, and Value.

The Name, type, value and message body must not be empty or null.

(string) - The name of the message attributes

(map) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data, encrypted data, or images.

(string) -[Required] Type of message attributes

EQS support the following data type

Binary, Number, String

MessageSystemAttributes (map) -

Each message system attribute consists of a Name, Type, and Value.

Name, type, value and the message body must not be empty or null.

(string) - The name of the message attributes

(map) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data,

encrypted data, or images.

(string) - Type of message attributes

EQS support following data type

Binary , Number , String

Response Syntax

{
   "Successful": [
          {
                "Id": "MESSAGE_ID",
                "MessageId": "MESSAGE_ID",
                "MD5OfMessageBody": "MD5_HASH",
                "MD5OfMessageAttributes": "MD5_HASH",
                "MD5OfMessageSystemAttributes": "MD5_HASH",
                "SequenceNumber": "SEQUENCE_NUMBER"
          }
   ],
   "Failed": []
}

Set queue Attributes

Request Syntax

import { SQS } from 'aws-sdk';
const eqs_client = new SQS();

var params = {
   QueueUrl: 'STRING_VALUE', /* required */
   Attributes: {
         'AttributeName1': 'AttributeValue1',
         'AttributeName2': 'AttributeValue2',
        }
};
eqs_client.setQueueAttributes(params, function(err, data) {
   if (err) console.log(err, err.stack);
   else     console.log(data);
});

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue of which attributes should be set.

Attributes (map)[Required]

A map of attributes to set.

Response Syntax

None

Tag queue

Request Syntax

import { SQS } from 'aws-sdk';
const eqs_client = new SQS();

const params = {
   QueueUrl: 'YOUR_QUEUE_URL',
   Tags: {
          'YOUR_TAG_KEY': 'YOUR_TAG_VALUE',
   }
};

eqs_client.tagQueue(params, (err, data) => {
   if (err) {
          console.log('Error', err);
   } else {
          console.log('Queue tagged successfully');
   }
});

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue.

Tags (map) - [Required]

The list of tags to be added to the specified queue.

Response Syntax

None

Untag queue

Request Syntax

import { SQS } from 'aws-sdk';
const eqs_client = new SQS();

var params = {
   QueueUrl: 'STRING_VALUE', /* required */
   TagKeys: [
         'STRING_VALUE',
   ]
};

eqsClient.untagQueue(params, function(err, data) {
   if (err) console.log(err, err.stack);
   else     console.log(data);
});

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue.

TagKeys (list) - [Required]

The list of tags to be removed from the specified queue.

Response Syntax

None

Java SDK

1 - Install java and maven

2 - go to project directory and enter the command

mvn archetype:generate \
-DarchetypeGroupId=software.amazon.awssdk \
-DarchetypeArtifactId=archetype-app-quickstart \
-DarchetypeVersion=2.18.16

Enter the prompt values

Prompt

Value to enter

Define value for property ‘service’:

s3

Define value for property ‘httpClient’:

apache-client

Define value for property ‘nativeImage’:

false

Define value for property ‘groupId’:

org.example

Define value for property ‘artifactId’:

getstarted

Define value for property ‘version’ 1.0-SNAPSHOT:

<Enter>

Define value for property ‘package’ org.example:

<Enter>

3 - your project directory would look something like this

|----getstarted
├── README.md
├── pom.xml
└── src
        ├── main
        │   ├── java
        │   │   └── org
        │   │       └── example
        │   │           ├── App.java
        │   │           ├── DependencyFactory.java
        │   │           └── Handler.java
        │   └── resources
        │       └── simplelogger.properties
        └── test
                └── java
                        └── org
                                └── example
                                        └── HandlerTest.java

10 directories, 7 files

your app.java file

package org.example;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class App {
        private static final Logger logger =
                        LoggerFactory.getLogger(App.class);

        public static void main(String... args) {
                        logger.info("Application starts");

                        Handler handler = new Handler();

                //you can call function of handler through handler object

                logger.info("Application ends");
        }
}

4 - make connection with the EQS client

To make the connection with the EQS client , you need to pass configurations and credentials.

Configurations-

region_name- your_region
endpoint_url - eqs_endpoint_url (provided by e2e networks eqs service)

Credentials-

aws_access_key_id - your_access_key_id
aws_secret_key_id - your_secret_key_id

Make connection with EQS

There are many ways to provide credentials and configuration to connect with EQS service -

a) providing credentials directly to client object -

warning - Hardcoded credentials in application is not recommended

Update your DependencyFactory.java file

package org.example;

import java.net.URI;

import software.amazon.awssdk.auth.credentials.*;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.sqs.*;

public class DependencyFactory {
        private DependencyFactory() {}
        public static SqsClient sqsClient() {
                AwsCredentialscredentials=AwsBasicCredentials.create(“your_
                access_key_id”, “your_secret_access_key”);
                URI endpointUri = URI.create("your e2e eqs access url");
                Region region = Region.of("elasticmq");

                SqsClient eqs_client = SqsClient.builder()
                        .credentialsProvider(StaticCredentialProvider.create(credentials))
                        .endpointOverride(endpointUri)
                        .region(region)
                        .build();

                return eqs_client;
        }

}

b) you can put credentials and configurations in the config and credentials file , and these files should be located at ~/.aws/config, ~/.aws/credentials location, client will automaticlay access these credentials and configurations.

put in ~/.aws/credentials file

[default]
region = “your_region”

put in ~/.aws/configuration file

[default]
aws_access_key_id = “your access key id”
aws_secret_access_key = “your secret key”

Update your DependencyFactory.java file

package org.example;

import java.net.URI;

import software.amazon.awssdk.auth.credentials.*;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.sqs.SqsClient;

public class DependencyFactory {

        private DependencyFactory() {}

        public static SqsClient sqsClient() {
                AwsCredentialsProvider credentialsProvider = DefaultCredentialsProvider.builder().build();
                Region region = Region.of(new DefaultAwsRegionProviderChain().getRegion());
                URI endpointUri = URI.create("e2e_eqs_access_url");
                SqsClient eqs_client = SqsClient.builder()
                                .credentialsProvider(credentialsProvider)
                                .endpointOverride(endpointUri)
                                .region(region)
                                .build();
                return eqs_client;
        }

c) you can make the connection with the EQS client by passing the credentials and configuration into the environment variables file.

using terminal (Linux, OS X or Unix)

$ export AWS_ACCESS_KEY_ID = your_access_key_id
$ export AWS_SECRET_ACCESS_KEY = your_secret_key
$ export AWS_DEFAULT_REGION = your_eqs_region

using terminal (Windows)

> set AWS_ACCESS_KEY_ID = your_access_key_id
> set AWS_SECRET_ACCESS_KEY = your_secret_key
> set AWS_DEFAULT_REGION = your_eqs_region

or, edit your enviourment valiable file

AWS_ACCESS_KEY_ID = your_access_key_id
AWS_SECRET_ACCESS_KEY = your_secret_access_key
AWS_DEFAULT_REGION = your_eqs_region

pom.xml file

<dependency>
        <groupId>io.github.cdimascio</groupId>
        <artifactId>dotenv-java</artifactId>
        <version>2.2.0</version>
</dependency>

update your DependencyFactory.java

import io.github.cdimascio.dotenv.Dotenv;
import software.amazon.awssdk.auth.credentials.*;
import software.amazon.awssdk.regions.*;
import software.amazon.awssdk.services.sqs.*;

public class DependencyFactory {

        public static SqsClient sqsClient() {
                Dotenv dotenv = Dotenv.load();
                AwsCredentials credentials = AwsBasicCredentials.create(
                        dotenv.get("AWS_ACCESS_KEY_ID"),
                        dotenv.get("AWS_SECRET_ACCESS_KEY")
                );
                Region region = Region.of(dotenv.get("AWS_REGION"));
                URI endpointUri = URI.create("e2e_eqs_access_url");

                SqsClient eqs_client = SqsClient.builder()
                .credentialsProvider(StaticCredentialsProvider.create(credentials))
                .endpointOverride(endpointUri)
                .region(region)
                .build();

                return eqs_client;
        }
}

Methods available in eqs_client

necessary imports

import com.amazonaws.services.sqs.*;
import com.amazonaws.services.sqs.model.*;

Change VisibilityTimeout

Request Syntax

your .java file

String queueUrl = "queue_url";

ChangeMessageVisibilityRequest request = ChangeMessageVisibilityRequest.builder()
        .queueUrl(queueUrl)
        .receiptHandle("example-receipt-handle")
        .visibilityTimeout(60)
        .build();

eqs_client.changeMessageVisibility(request);

System.out.println("Message visibility timeout changed successfully!");

Parameters

QueueUrl (string)- [Required]

The URL of the E2E EQS queue whose message’s visibility is changed.

ReceiptHandle (string) - [Required]

The receipt handle is associated with the message whose visibility timeout is changed. This parameter is returned by the ReceiveMessage action

VisibilityTimeout (integer) - [Required]

The new value for the message’s visibility timeout (in seconds)

Response Syntax

void

Change VisibilityTimeout in batch

Request Syntax

edit your .java file

final String queueUrl = "your_queue_url_here";

ChangeMessageVisibilityBatchRequest request = new ChangeMessageVisibilityBatchRequest()
        .withQueueUrl(queueUrl)
        .withEntries(
                new ChangeMessageVisibilityBatchRequestEntry()
                        .withId("message_1")
                        .withReceiptHandle("receipt_handle_1")
                        .withVisibilityTimeout(3600),
                new ChangeMessageVisibilityBatchRequestEntry()
                        .withId("message_2")
                        .withReceiptHandle("receipt_handle_2")
                        .withVisibilityTimeout(600)
        );

ChangeMessageVisibilityBatchResponse response = eqs_client.changeMessageVisibilityBatch(request);

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue whose message’s visibility is changed.

Entries (ArrayList/LinkList) - [Required]

(objects)

id [Required]-(string) An identifier for this particular receipt handle used to communicate the result

ReceiptHandle [Required] -(string) A receipt handle

VisibilityTimeout - (integer) The new value (in seconds) for the message’s visibility timeout

Response Syntax

ChangeMessageVisibilityBatchResult {
        Successful: [
                ChangeMessageVisibilityBatchResultEntry {
                        Id: "message_1",
                        SenderFault: false
                }
        ],
        Failed: [
                ChangeMessageVisibilityBatchResultEntry {
                        Id: "message_2",
                        SenderFault: true,
                        Code: "InvalidParameterValue",
                        Message: "message"
                }
        ]
}

Close connection

Request Syntax

edit your .java file

eqs_client.close()

Response Syntax

None

Create queue

Request Syntax

edit your .java file

CreateQueueRequest request = new CreateQueueRequest()
        .withQueueName("string")
        .withAttributes(Map.of(
                "DelaySeconds", "123",
                "MaximumMessageSize", "456",
                "MessageRetentionPeriod", "789",
                "ReceiveMessageWaitTimeSeconds", "10",
                "VisibilityTimeout", "30"
        ))
        .withTags(Map.of(
                "tag1", "value1",
                "tag2", "value2"
        ));

CreateQueueResponse response = eqs_client.createQueue(request);

String queueUrl = response.getQueueUrl();

Parameters

QueueName (string)- [Required]

1 - A queue name can have up to 80 characters

2 - Valid values: alphanumeric characters, hyphens ( -), and underscores ( _).

Attributes (Map/HashMap)- Attributes could be

1 - DelaySeconds - Time(second), to which extent delivery of messages is delayed in the queue

Valid values - 0 to 900 (second)

default - 0 (second)

2 - MaximumMessageSize - The size of the message after which the queue will reject the message

Valid values - 1,024 bytes (1 KiB) to 262,144 bytes (256 KiB)

default - 262,144 bytes(256 KiB)

3 - MessageRetentionPeriod - Time to which extent a queue will retain a message

Valid values - 60 seconds (1 minute) to 1,209,600 seconds (14 days)

default - 345,600 (4 days)

4 - ReceiveMessageWaitTimeSeconds - Time to which extent ReceiveMessage action waits before receiving a message

Valid values - 0 to 20 (seconds)

default - 0 (second)

5 - VisibilityTimeout - The amount of time that a message in a queue is invisible to other consumers after a consumer retrieves it.

Valid values - 0 to 43,200 seconds (12 hours)

default - 30 second

tags (Map/HashMap) -

1 - Adding more than 50 tags to a queue isn’t recommended.

2 - A new tag with a key identical to that of an existing tag overwrites the existing tag.

Response Syntax

{ "QueueUrl": "string" }

Delete message

Request Syntax

edit your .java file

DeleteMessageRequest request = new DeleteMessageRequest()
        .withQueueUrl("string")
        .withReceiptHandle("string");
eqs_client.deleteMessage(request);

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which messages are deleted.

ReceiptHandle (string) - [Required]

The receipt handle is associated with the message to delete.

Response Syntax

void

Delete message in batch

Request Syntax

edit your .java file

DeleteMessageBatchRequest request = new DeleteMessageBatchRequest()
        .withQueueUrl("string")
        .withEntries(
                new DeleteMessageBatchRequestEntry()
                        .withId("string")
                        .withReceiptHandle("string"),
                new DeleteMessageBatchRequestEntry()
                        .withId("string")
                        .withReceiptHandle("string"),
        );
DeleteMessageBatchResult result = eqs_client.deleteMessageBatch(request);

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which messages are deleted.

Entries (ArrayList/LinkList) - [Required]

(objects) id [Required]-(string) An identifier for this particular receipt handle used to communicate the result ReceiptHandle [Required] -(string) A receipt handle

Response Syntax

public class DeleteMessageBatchResult {
        private List<DeleteMessageBatchResultEntry> successful;
        private List<BatchResultErrorEntry> failed;
}

public class DeleteMessageBatchResultEntry {
        private String id;
}

public class BatchResultErrorEntry {
        private String id;
        private boolean senderFault;
        private String code;
        private String message;
}

Delete queue

Request Syntax

String queueUrl = "your_queue_url_here";
DeleteQueueRequest request = new DeleteQueueRequest(queueUrl);
eqs_client.deleteQueue(request);

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue to delete.

Response Syntax

void

Get queue attributes

Request Syntax

edit your .java file

GetQueueAttributesRequest request = new GetQueueAttributesRequest()
        .withQueueUrl("queue_url")
        .withAttributeNames("All");

GetQueueAttributesResult result = sqsClient.getQueueAttributes(request);

Map<String, String> attributes = result.getAttributes();

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which attributes are get.

AttributeNames (ArrayList/LinkList) - [Optional]

A list of attributes for which to retrieve information

All - it specifies, returns all values

you can also specify specific attributes in the list

As - (‘VisibilityTimeout’ , ‘MaximumMessageSize’ , ‘MessageRetentionPeriod’ , ‘ApproximateNumberOfMessages’ ,’ApproximateNumberOfMessagesNotVisible’ , ‘CreatedTimestamp’ , ‘LastModifiedTimestamp’ , ‘QueueArn’ , ‘ApproximateNumberOfMessagesDelayed’ , ‘DelaySeconds’ , ‘ReceiveMessageWaitTimeSeconds’)

Response Syntax

GetQueueAttributesResult{attributes={
        VisibilityTimeout=30,
        MaximumMessageSize=262144,
        MessageRetentionPeriod=345600,
        ApproximateNumberOfMessages=0,
        ApproximateNumberOfMessagesNotVisible=0,
        CreatedTimestamp=Tue Apr 27 05:00:00 UTC 2021,
        LastModifiedTimestamp=Tue Apr 27 05:00:00 UTC 2021,
}}

Get queue url

Request Syntax

edit your .java file

GetQueueUrlResult result = eqs_client.getQueueUrl(GetQueueUrlRequest.builder().queueName(queue_name).build());
String queueUrl = result.queueUrl();

Parameters

QueueName (string) -[Required]

The name of the queue whose URL must be fetched.

Response Syntax

{'QueueUrl': 'string'}

List queue tags

Request Syntax

edit your .java file

SqsClient sqsClient = SqsClient.create();
String queueUrl = "YOUR_QUEUE_URL";

ListQueueTagsRequest Request = ListQueueTagsRequest.builder()
        .queueUrl(queueUrl)
        .build();

ListQueueTagsResponse Response = sqsClient.listQueueTags(Request);

//..

System.out.println("Queue Tags: " + Response.tags());

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue of which all the tags must be listed.

Response Syntax

{
  "Tags": {
        "TagKey1": "TagValue1",
        "TagKey2": "TagValue2",
        }
}

List queues

Request Syntax

edit your .java file

ListQueuesRequest Request = ListQueuesRequest.builder()
                .queueNamePrefix("YOUR_QUEUE_NAME_PREFIX")
                .maxResults(10)
                .build();

ListQueuesResponse Response = sqsClient.listQueues(Request);

System.out.println("Queue URLs: " + Response.queueUrls());
Parameters
QueueNamePrefix (string) - [Optional]

A string to use for filtering the list results. Only those queues whose name begins with the specified string are returned.

MaxResults (integer) - [Optional]

The maximum number of results to include in the response. Valid values - 1 to 1000

Response Syntax

{
  "QueueUrls": ["string", ],
}

Purge queue

delete all the messages from queue.

Request Syntax

edit your .java file

String queueUrl = "queue_url";

PurgeQueueRequest purgeRequest = new PurgeQueueRequest(queueUrl);
PurgeQueueResult purgeResult = eqs_client.purgeQueue(purgeRequest);
System.out.println("Messages purged from queue " + queueUrl + ".");

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue of which all the messages must be deleted.

Response Syntax

void

Receive message

Request Syntax

edit your .java file

String queueUrl = "your_queue_url_here";

ReceiveMessageRequest Request = new ReceiveMessageRequest(queueUrl)
        .withAttributeNames("All") // can specify specific attributes as well
        .withMessageAttributeNames("your_message_attribute_name_here")
        .withMaxNumberOfMessages(2)
        .withVisibilityTimeout(25)
        .withWaitTimeSeconds(10)
        .withReceiveRequestAttemptId("your_receive_request_attempt_id_here");

ReceiveMessageResult Result = eqs_client.receiveMessage(Request);

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which messages are received.

AttributeNames (ArrayList/LinkList) -

A list of attributes that need to be returned along with each message.

All - it specifies, returns all values

you can also specify specific attributes in the list

As - (‘VisibilityTimeout’ , ‘MaximumMessageSize’ , ‘MessageRetentionPeriod’ , ‘ApproximateNumberOfMessages’ ,’ApproximateNumberOfMessagesNotVisible’ , ‘CreatedTimestamp’ , ‘LastModifiedTimestamp’ , ‘QueueArn’ , ‘ApproximateNumberOfMessagesDelayed’ , ‘DelaySeconds’ , ‘ReceiveMessageWaitTimeSeconds’)

MessageAttributeNames (ArrayList/LinkList) -

The name of the message attribute.

MaxNumberOfMessages (integer) -

The maximum number of messages to return.

Valid range - 1 to 10

default - 1

VisibilityTimeout (integer) -

The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request.

WaitTimeSeconds (integer) -

The duration (in seconds) for which the call waits for a message to arrive in the queue before returning.

Response Syntax

{
  "Messages": [
        {
        "MessageId": "message_id",
        "ReceiptHandle": "receipt_handle",
        "MD5OfBody": "message_body_hash",
        "Body": "message_body",
        "Attributes": {
                "ApproximateReceiveCount": "1",
                "SentTimestamp": "send_time_stamp",
                "SenderId": "sender_id",
                "ApproximateFirstReceiveTimestamp": "approx_first_receive_time_stamp"
        },
        "MD5OfMessageAttributes": "message_attributes_hash",
        "MessageAttributes": {
                "MyAttribute": {
                "StringValue": "string_value",
                "DataType": "String"
                }
        }
        },
  ]
}

Send Message

Request Syntax

edit your .java file

String queueUrl = "QUEUE_URL";
String messageBody = "MESSAGE_BODY";
int delaySeconds = 0; // optional

SendMessageRequest request = new SendMessageRequest()
                .withQueueUrl(queueUrl)
                .withMessageBody(messageBody)
                .withDelaySeconds(delaySeconds);

// Optional message attributes
Map<String, MessageAttributeValue> messageAttributes = new HashMap<>();
messageAttributes.put("Attribute1", new MessageAttributeValue()
                .withDataType("String")
                .withStringValue("Value1"));
messageAttributes.put("Attribute2", new MessageAttributeValue()
                .withDataType("Number")
                .withStringValue("123"));
request.setMessageAttributes(messageAttributes);

// Optional message system attributes
Map<String, MessageSystemAttributeValue> messageSystemAttributes = new HashMap<>();
messageSystemAttributes.put("SystemAttribute1", new MessageSystemAttributeValue()
                .withDataType("String")
                .withStringValue("Value1"));
messageSystemAttributes.put("SystemAttribute2", new MessageSystemAttributeValue()
                .withDataType("Number")
                .withStringValue("123"));
request.setMessageSystemAttributes(messageSystemAttributes);

SendMessageResult result = eqs_client.sendMessage(request);

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue to which messages are send.

MessageBody (string) - [Required]

The message to send. The minimum size is one character. The maximum size is 256 KB.

DelaySeconds (integer) -

The length of time, in seconds, for which to delay a specific message.

MessageAttributes (Map/HashMap) -

Each message attribute consists of a Name, Type, and Value .

Name, type, value and the message body must not be empty or null .

(string) - name of the message attributes

(Map/HashMap) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data,

encrypted data, or images.

(string) - [Required] Type of message attributes

EQS support the following data type

Binary, Number, String

MessageSystemAttributes (Map/HashMap) -

Each message system attribute consists of a Name, Type, and Value.

The name, type, value and message body must not be empty or null.

(string) - the name of the message attributes

(Map/HashMap) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data,

encrypted data, or images.

(string) - Type of message attributes

EQS support the following data type

Binary , Number , String

Response Syntax

{
   MessageId: string
   MD5OfMessageBody: string
   MD5OfMessageAttributes: string
   MD5OfMessageSystemAttributes: string
   SequenceNumber: string
}

string reprasent actual value return by the method

Send message in batch

Request Syntax

edit your .java file

SendMessageBatchRequest Request = new SendMessageBatchRequest()
  .withQueueUrl("string")
  .withEntries(new SendMessageBatchRequestEntry()
        .withId("string")
        .withMessageBody("string")
        .withDelaySeconds(123)
        .withMessageAttributes(Collections.singletonMap(
                        "string",
                        new MessageAttributeValue()
                                .withDataType("string")
                                .withStringValue("string")
                                .withBinaryValue(ByteBuffer.wrap(new byte[]{}))
        ))
        .withMessageSystemAttributes(Collections.singletonMap(
                        "string",
                        new MessageSystemAttributeValue()
                                .withDataType("string")
                                .withStringValue("string")
                                .withBinaryValue(ByteBuffer.wrap(new byte[]{}))
        )),
        new SendMessageBatchRequestEntry()
        .withId("string")
        .withMessageBody("string")
        .withDelaySeconds(100)
        .withMessageAttributes(Collections.singletonMap(
                        "string",
                        new MessageAttributeValue()
                                .withDataType("string")
                                .withStringValue("string")
                                .withBinaryValue(ByteBuffer.wrap(new byte[]{}))
        ))
        .withMessageSystemAttributes(Collections.singletonMap(
                        "string",
                        new MessageSystemAttributeValue()
                                .withDataType("string")
                                .withStringValue("string")
                                .withBinaryValue(ByteBuffer.wrap(new byte[]{}))
        )),
  );
SendMessageBatchResult result = eqs_client.sendMessageBatch(Request);

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue to which messages are sent.

Entries (ArrayList/LinkList) - [Required]

A list of SendMessageBatchRequestEntry items.

(Map/HashMap) -

Contains the details of a single E2E EQS message along with an Id.

Id (string) - [REQUIRED]

An identifier for a message in this batch is used to communicate the result.

MessageBody (string) - [Required]

The message to send. The minimum size is one character. The maximum size is 256 KB.

DelaySeconds (integer) -

The length of time, in seconds, for which to delay a specific message.

MessageAttributes (map) -

Each message attribute consists of a Name, Type, and Value.

The Name, type, value and message body must not be empty or null.

(string) - The name of the message attributes

(map) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data, encrypted data, or images.

(string) -[Required] Type of message attributes

EQS support the following data type

Binary, Number, String

MessageSystemAttributes (Map/HashMap) -

Each message system attribute consists of a Name, Type, and Value.

Name, type, value and the message body must not be empty or null.

(string) - The name of the message attributes

(Map/HashMap) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data,

encrypted data, or images.

(string) - Type of message attributes

EQS support following data type

Binary , Number , String

Response Syntax

public class SendMessageBatchResult {
        private List<SendMessageBatchResultEntry> successful;
        private List<BatchResultErrorEntry> failed;
}

public class SendMessageBatchResultEntry {
        private String id;
        private String messageId;
        private String mD5OfMessageBody;
        private String mD5OfMessageAttributes;
        private String mD5OfMessageSystemAttributes;
        private String sequenceNumber;
}

public class BatchResultErrorEntry {
        private String id;
        private Boolean senderFault;
        private String code;
        private String message;
}

Set queue Attributes

Request Syntax

edit your .java file

String queueUrl = "your_queue_url";
Map<String, String> attributes = new HashMap<>();
attributes.put("AttributeName", "AttributeValue");

SetQueueAttributesRequest request = new SetQueueAttributesRequest()
        .withQueueUrl(queueUrl)
        .withAttributes(attributes);

SetQueueAttributesResult result = eqs_client.setQueueAttributes(request);

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue of which attributes should be set.

Attributes[Required]

A map of attributes to set.

Response Syntax

void

Tag Queue

Request Syntax

edit your .java file

String queueUrl = "QUEUE_URL";
Map<String, String> tags = new HashMap<>();
tags.put("tag1", "value1");
tags.put("tag2", "value2");

TagQueueRequest Request = new TagQueueRequest()
        .withQueueUrl(queueUrl)
        .withTags(tags);

TageQueueResult Result = eqs_client.tagQueue(Request);

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue.

Tags - [Required]

The map of tags to be added to the specified queue.

Response Syntax

void

Untag queue

Request Syntax

edit your .java file

List<String> tagKeys = Arrays.asList("tag-key-1", "tag-key-2", "tag-key-3");
UntagQueueRequest Request = new UntagQueueRequest()
        .withQueueUrl("queue-url")
        .withTagKeys(tagKeys);

UntagqueueResult Result = sqsClient.untagQueue(Request);

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue.

TagKeys (ArrayList/LinkList) - [Required]

The list of tags to be removed from the specified queue.

Response Syntax

void

Ruby SDK

1 - install gem and then install aws sdk for ruby

If your project uses Bundler, add the following line to your Gemfile to add the AWS SDK for Ruby to your project.

gem 'aws-sdk'

If you don’t use Bundler, the easiest way to install the SDK is to use RubyGems. To install the latest version of the SDK, use the following command.

gem install aws-sdk

If the previous command fails on your Unix-based system, use sudo to install the SDK, as shown in the following command.

sudo gem install aws-sdk

2 - Make a connection with the EQS client.

To make the connection with the EQS client , you need to pass configurations and credentials.

Configurations-

region_name- your_region
endpoint_url - eqs_endpoint_url (provided by e2e networks eqs service)

Credentials-

aws_access_key_id - your_access_key_id
aws_secret_key_id - your_secret_key_id

Make connection with EQS

You can establish the connection with the EQS client in several ways.

a) You can directly pass the credentials and configurations at the time of making a session with the EQS client. warning - Hardcoded credentials in application is not recommended

edit your .rb file

require 'aws-sdk-sqs'

eqs_client = Aws::SQS::Client.new(
        endpoint: “eqs_endpoint_url_provided_by_e2e”,
        region:”your_region”,
        credentials: Aws::Credentials.new(aws_access_key_id,aws_secret_access_key)
        )

b) you can put credentials and configurations in the config and credentials file , and these files should be located at ~/.aws/config, ~/.aws/credentials location.

put into ~/.aws/config file

[default]
region =REGION

put into ~/.aws/credentials file

[default]
aws_access_key_id = ACCESS_KEY_ID
aws_secret_access_key = SECRET_KEY

edit your .rb file

require 'aws-sdk-sqs'

eqs_client = Aws::SQS::Client.new(
        endpoint: “eqs_endpoint_url_provided_by_e2e”
        )

c) you can make the connection with the EQS client by passing the credentials and configuration into the environment variables file.

To install the python dotenv package, you can use the command

gem install dotenv

using terminal (Linux, OS X or Unix)

$ export AWS_ACCESS_KEY_ID = your_access_key_id
$ export AWS_SECRET_ACCESS_KEY = your_secret_key
$ export AWS_DEFAULT_REGION = your_eqs_region

using terminal (Windows)

> set AWS_ACCESS_KEY_ID = your_access_key_id
> set AWS_SECRET_ACCESS_KEY = your_secret_key
> set AWS_DEFAULT_REGION = your_eqs_region

or, edit your enviourment valiable file

AWS_ACCESS_KEY_ID = your_access_key_id
AWS_SECRET_ACCESS_KEY = your_secret_access_key
AWS_DEFAULT_REGION = your_eqs_region

edit your .rb file

require 'aws-sdk-sqs'
require 'dotenv/load'

eqs_client = Aws::SQS::Client.new({
        region: ENV['AWS_REGION'],
        access_key_id: ENV['AWS_ACCESS_KEY_ID'],
        secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
        endpoint: ENV['AWS_SQS_ENDPOINT']
        })

Methods available in eqs_client

Change VisibilityTimeout

Request Syntax

queue_url = "your_queue_url_here"
receipt_handle = "your_receipt_handle_here"
visibility_timeout = 123

resp = eqs_client.change_message_visibility({
queue_url: queue_url,
receipt_handle: receipt_handle,
visibility_timeout: visibility_timeout
})

Parameters

QueueUrl (string)- [Required]

The URL of the E2E EQS queue whose message’s visibility is changed.

ReceiptHandle (string) - [Required]

The receipt handle is associated with the message whose visibility timeout is changed. This parameter is returned by the ReceiveMessage action

VisibilityTimeout (integer) - [Required]

The new value for the message’s visibility timeout (in seconds)

Response Syntax

nil

Change VisibilityTimeout in batch

Request Syntax

response = eqs_client.change_message_visibility_batch({
        queue_url: "string",
        entries: [
                {
                id: "string",
                receipt_handle: "string",
                visibility_timeout: 123,
                },
        ],
})

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue whose message’s visibility is changed.

Entries (Array) - [Required]

(Hash)

id [Required]-(string) An identifier for this particular receipt handle used to communicate the result

ReceiptHandle [Required] -(string) A receipt handle

VisibilityTimeout - (string) The new value (in seconds) for the message’s visibility timeout

Response Syntax

{
  successful: [
        {
          id: "string",
        },
  ],
  failed: [
        {
          id: "string",
          sender_fault: true | false,
          code: "string",
          message: "string",
        },
  ],
}

Create queue

Request Syntax

queue_name = "my-queue"
        attributes = {
        "DelaySeconds" => "0",
        "MaximumMessageSize" => "262144",
        "MessageRetentionPeriod" => "345600",
        "ReceiveMessageWaitTimeSeconds" => "0",
        "VisibilityTimeout" => "30"
        }
tags = {
        "tag-key" => "tag-value"
}

resp = eqs_client.create_queue({
        queue_name: queue_name,
        attributes: attributes,
        tags: tags
})

Parameters

QueueName (string)- [Required]

1 - A queue name can have up to 80 characters

2 - Valid values: alphanumeric characters, hyphens ( -), and underscores ( _).

Attributes (Hash)- Attributes could be

1 - DelaySeconds - Time(second), to which extent delivery of messages is delayed in the queue

Valid values - 0 to 900 (second)

default - 0 (second)

2 - MaximumMessageSize - The size of the message after which the queue will reject the message

Valid values - 1,024 bytes (1 KiB) to 262,144 bytes (256 KiB)

default - 262,144 bytes(256 KiB)

3 - MessageRetentionPeriod - Time to which extent a queue will retain a message

Valid values - 60 seconds (1 minute) to 1,209,600 seconds (14 days)

default - 345,600 (4 days)

4 - ReceiveMessageWaitTimeSeconds - Time to which extent ReceiveMessage action waits before receiving a message

Valid values - 0 to 20 (seconds)

default - 0 (second)

5 - VisibilityTimeout - The amount of time that a message in a queue is invisible to other consumers after a consumer retrieves it.

Valid values - 0 to 43,200 seconds (12 hours)

default - 30 second

tags (Hash) -

1 - Adding more than 50 tags to a queue isn’t recommended.

2 - A new tag with a key identical to that of an existing tag overwrites the existing tag.

Response Syntax

{
   queue_url: "string"
}

Delete message

Request Syntax

eqs_client.delete_message(
        queue_url: "string",
        receipt_handle: "string"
)

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which messages are deleted.

ReceiptHandle (string) - [Required]

The receipt handle is associated with the message to delete.

Response Syntax

nil

Delete message in batch

Request Syntax

response = sqs_client.delete_message_batch({
        queue_url: "string", # required
        entries: [
                {
                id: "string", # required
                receipt_handle: "string", # required
                },
        ],
})

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which messages are deleted.

Entries (Array) - [Required]

(Hash) id [Required]-(string) An identifier for this particular receipt handle used to communicate the result ReceiptHandle [Required] -(string) A receipt handle

Response Syntax

{
  successful: [
        {
        id: "string",
        },
  ],
  failed: [
        {
        id: "string",
        sender_fault: false,
        code: "string",
        message: "string",
        },
  ],
}

Delete queue

Request Syntax

resp = eqs_client.delete_queue({
        queue_url: "String", # required
})

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue to delete.

Response Syntax

nil

Get queue Attributes

Request Syntax

queue_url = "your_queue_url"
attribute_names = ["All"]


resposne = sqs.get_queue_attributes({
        queue_url: queue_url,
        attribute_names: attribute_names
})

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which attributes are get.

AttributeNames (Array<String>) - [Optional]

A list of attributes for which to retrieve information

All - it specifies, returns all values

you can also specify specific attributes in the list

As - [‘VisibilityTimeout’ , ‘MaximumMessageSize’ , ‘MessageRetentionPeriod’ , ‘ApproximateNumberOfMessages’ ,’ApproximateNumberOfMessagesNotVisible’ , ‘CreatedTimestamp’ , ‘LastModifiedTimestamp’ , ‘QueueArn’ , ‘ApproximateNumberOfMessagesDelayed’ , ‘DelaySeconds’ , ‘ReceiveMessageWaitTimeSeconds’]

Response Syntax

{
  attributes: {
        attribute_name1: "attribute_value1",
        attribute_name2: "attribute_value2",
  }
}

Get queue url

Request Syntax

queue_name = "queue-name"
resp = sqs.get_queue_url(queue_name: queue_name)

Parameters

QueueName (string) -[Required]

The name of the queue whose URL must be fetched.

Response Syntax

{
  queue_url: "string"
}

List queue tags

Request Syntax

queue_url = "queue_url"

resp = sqs.list_queue_tags({
    queue_url: queue_url
})

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue of which all the tags must be listed.

Response Syntax

{
  "Tags" => {
        "Key1" => "Value1",
        "Key2" => "Value2",
  }
}

List queues

Request Syntax

queue_name_prefix = 'my-queue'
max_results = 10

resp = sqs.list_queues({
        queue_name_prefix: queue_name_prefix,
        max_results: max_results
})
Parameters
QueueNamePrefix (string) - [Optional]

A string to use for filtering the list results. Only those queues whose name begins with the specified string are returned.

MaxResults (integer) - [Optional]

The maximum number of results to include in the response. Valid values - 1 to 1000

Response Syntax

{
  queue_urls: ["string"]
}

Purge queue

delete all the messages from queue.

Request Syntax

queue_url = "queue_url"

resp = sqs.purge_queue({
  queue_url: queue_url
})

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue of which all the messages must be deleted.

Response Syntax

nil

Receive message

Request Syntax

resp = sqs_client.receive_message({
        queue_url: "string",
        attribute_names: ["All"],
        message_attribute_names: ["string"],
        max_number_of_messages: 2,
        visibility_timeout: 25,
        wait_time_seconds: 10,
        receive_request_attempt_id: "string",
})

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which messages are received.

AttributeNames (Array) -

A list of attributes that need to be returned along with each message.

All - it specifies, returns all values

you can also specify specific attributes in the list

As - [‘VisibilityTimeout’ , ‘MaximumMessageSize’ , ‘MessageRetentionPeriod’ , ‘ApproximateNumberOfMessages’ ,’ApproximateNumberOfMessagesNotVisible’ , ‘CreatedTimestamp’ , ‘LastModifiedTimestamp’ , ‘QueueArn’ , ‘ApproximateNumberOfMessagesDelayed’ , ‘DelaySeconds’ , ‘ReceiveMessageWaitTimeSeconds’]

MessageAttributeNames (Array) -

The name of the message attribute.

MaxNumberOfMessages (integer) -

The maximum number of messages to return.

Valid range - 1 to 10

default - 1

VisibilityTimeout (integer) -

The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request.

WaitTimeSeconds (integer) -

The duration (in seconds) for which the call waits for a message to arrive in the queue before returning.

Response Syntax

{
  messages: [
        {
        message_id: "string",
        receipt_handle: "string",
        md5_of_body: "string",
        body: "string",
        attributes: {"string" => "string"},
        md5_of_message_attributes: "string",
        message_attributes: {
                "string" => {
                string_value: "string",
                binary_value: "bytes",
                data_type: "string",
                }
        }
        },
  ]
}

Send message

Request Syntax

resp = sqs.send_message({
      queue_url: "QUEUE_URL",
  message_body: "MESSAGE_BODY",
      delay_seconds: 123,
      message_attributes: {
            "ATTRIBUTE_NAME" => {
            string_value: "ATTRIBUTE_VALUE",
            data_type: "STRING" # EQS supports Binary, Number, String data types
            }
      },
      message_system_attributes: {
            "ATTRIBUTE_NAME" => {
            string_value: "ATTRIBUTE_VALUE",
            data_type: "STRING" # EQS supports Binary, Number, String data types
            }
      }
    })

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue to which messages are send.

MessageBody (string) - [Required]

The message to send. The minimum size is one character. The maximum size is 256 KB.

DelaySeconds (integer) -

The length of time, in seconds, for which to delay a specific message.

MessageAttributes (Hash) -

Each message attribute consists of a Name, Type, and Value .

Name, type, value and the message body must not be empty or null .

(string) - name of the message attributes

(Hash) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data,

encrypted data, or images.

(string) - [Required] Type of message attributes

EQS support the following data type

Binary, Number, String

MessageSystemAttributes (Hash) -

Each message system attribute consists of a Name, Type, and Value.

The name, type, value and message body must not be empty or null.

(string) - the name of the message attributes

(Hash) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data,

encrypted data, or images.

(string) - Type of message attributes

EQS support the following data type

Binary , Number , String

Response Syntax

{
  md5_of_message_body: "string",
  md5_of_message_attributes: "string",
  md5_of_message_system_attributes: "string",
  message_id: "string",
  sequence_number: "string"
}

Send message in batch

Request Syntax

resp = sqs_client.send_message_batch({
        queue_url: "QUEUE_URL",
        entries: [
                {
                id: "MESSAGE_ID_1",
                message_body: "MESSAGE_BODY_1",
                delay_seconds: 123,
                message_attributes: {
                        "ATTRIBUTE_NAME_1" => {
                        string_value: "ATTRIBUTE_VALUE_1",
                        data_type: "String", # "Binary" or "Number"
                        },
                },
                message_system_attributes: {
                        "SYS_ATTRIBUTE_NAME_1" => {
                        string_value: "SYS_ATTRIBUTE_VALUE_1",
                        data_type: "String", # "Binary" or "Number"
                        },
                }
                },
                {
                id: "MESSAGE_ID_2",
                message_body: "MESSAGE_BODY_2",
                delay_seconds: 456,
                message_attributes: {
                        "ATTRIBUTE_NAME_3" => {
                        string_value: "ATTRIBUTE_VALUE_3",
                        data_type: "String", # "Binary" or "Number"
                        },
                },
                message_system_attributes: {
                        "SYS_ATTRIBUTE_NAME_3" => {
                        string_value: "SYS_ATTRIBUTE_VALUE_3",
                        data_type: "String", # "Binary" or "Number"
                        },
                }
                },
        ]
})

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue to which messages are sent.

Entries (Array) - [Required]

A list of SendMessageBatchRequestEntry items.

(Hash) -

Contains the details of a single E2E EQS message along with an Id.

Id (string) - [REQUIRED]

An identifier for a message in this batch is used to communicate the result.

MessageBody (string) - [Required]

The message to send. The minimum size is one character. The maximum size is 256 KB.

DelaySeconds (integer) -

The length of time, in seconds, for which to delay a specific message.

MessageAttributes (Hash) -

Each message attribute consists of a Name, Type, and Value.

The Name, type, value and message body must not be empty or null.

(string) - The name of the message attributes

(Hash) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data, encrypted data, or images.

(string) -[Required] Type of message attributes

EQS support the following data type

Binary, Number, String

MessageSystemAttributes (Hash) -

Each message system attribute consists of a Name, Type, and Value.

Name, type, value and the message body must not be empty or null.

(string) - The name of the message attributes

(Hash) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data,

encrypted data, or images.

(string) - Type of message attributes

EQS support following data type

Binary , Number , String

Response Syntax

{
  successful: [
        {
        id: "string",
        message_id: "string",
        md5_of_message_body: "string",
        md5_of_message_attributes: "string",
        md5_of_message_system_attributes: "string",
        sequence_number: "string"
        }
  ],
  failed: [
        {
        id: "string",
        sender_fault: true | false,
        code: "string",
        message: "string"
        }
  ]
}

Set queue Attributes

Request Syntax

resp = sqs_client.set_queue_attributes({
  queue_url: "string", # required
  attributes: {
          "string" => "string",
        },
})

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue of which attributes should be set.

Attributes (Hash)[Required]

A map of attributes to set.

Response Syntax

nil

Tag queue

Request Syntax

sqs_client.tag_queue({
  queue_url: "QUEUE_URL",
  tags: {
        "TAG_NAME" => "TAG_VALUE",
  },
})

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue.

Tags (Hash) - [Required]

The list of tags to be added to the specified queue.

Response Syntax

nil

Untag queue

Request Syntax

queue_url = "QUEUE_URL"
tag_keys = ["TAG_KEY1", "TAG_KEY2"]
sqs.untag_queue({
  queue_url: queue_url,
  tag_keys: tag_keys,
})

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue.

TagKeys (Array) - [Required]

The list of tags to be removed from the specified queue.

Response Syntax

nil

PHP SDK

1 - Install php of version 5.5.0 or above .

2 - Install composer for your system .

3 - go to your directory and install aws-sdk for php using command

composer require aws/aws-sdk-php

4 - You can use the below given Composer command to install the latest version of the AWS SDK for PHP as a dependency.

php -d memory_limit=-1 composer.phar require aws/aws-sdk-php

4- Make a connection with the EQS client.

To make the connection with the EQS client , you need to pass configurations and credentials.

Configurations-

region_name- your_region
endpoint_url - eqs_endpoint_url (provided by e2e networks eqs service)

Credentials-

aws_access_key_id - your_access_key_id aws_secret_key_id - your_secret_key_id

Make connection with EQS

You can make the connection with the EQS client in three ways

a) You can directly pass the credentials and configurations at the time of making a session with the EQS client. warning - Hardcoded credentials in application is not recommended

edit your .php file

<?php
require 'vendor/autoload.php';

use Aws\Credentials\Credentials;
use Aws\Sqs\SqsClient;

$config = [
        'region' => “your region”,
        'version' => '2012-11-05, //version of sdk
        'endpoint' => “end_point_url_to_connect_with_eqs”
];

$credentials = new Credentials('eqs_access_key_id', “eqs_secret_access_key”);
$eqs_client = new SqsClient([
        'credentials' => $credentials,
        'region' => $config['region'],
        'version' => $config['version'],
        'endpoint' => $config['endpoint']
]);

?>
  1. you can put credentials and configurations in the config and credentials file , and these files should be located at ~/.aws/config, ~/.aws/credentials location.

put into ~/.aws/config file

[default]
region =REGION
put into ~/.aws/credentials file

put into ~/.aws/credentials file

[default]
aws_access_key_id = ACCESS_KEY_ID
aws_secret_access_key = SECRET_KEY

edit your .php file

<?php

require 'vendor/autoload.php';

use Aws\Sqs\SqsClient;
use Aws\Exception\AwsException;

$eqs_client = new SqsClient([
        'version'=>'2012-11-05',
        'region' => “your_region”,
        'endpoint' => “eqs_end_point_url_provided_by_e2e”
]);
?>
  1. you can make the connection with the EQS client by passing the credentials and configuration into the environment variables file.

Install the vlucas/phpdotenv package using Composer

composer require vlucas/phpdotenv

using terminal (Linux, OS X or Unix)

$ export AWS_ACCESS_KEY_ID = your_access_key_id
$ export AWS_SECRET_ACCESS_KEY = your_secret_key
$ export AWS_DEFAULT_REGION = your_eqs_region

using terminal (Windows)

> set AWS_ACCESS_KEY_ID = your_access_key_id
> set AWS_SECRET_ACCESS_KEY = your_secret_key
> set AWS_DEFAULT_REGION = your_eqs_region

or, edit your enviourment valiable file

AWS_ACCESS_KEY_ID = your_access_key_id
AWS_SECRET_ACCESS_KEY = your_secret_access_key
AWS_DEFAULT_REGION = your_eqs_region

edit your .php file

<?php
require_once __DIR__ . '/vendor/autoload.php';
use Aws\Sqs\SqsClient;
use Dotenv\Dotenv;

$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();

$eqs_client = new SqsClient([
                        'version' => '2012-11-05',
                        'region' => getenv(AWS_REGION'),
                        'credentials' => [
                        'key' => getenv('AWS_ACCESS_KEY_ID'),
                        'secret' => getenv('AWS_SECRET_ACCESS_KEY'),
                        ],
        ]);
?>

above eqs_client is an object which has all methods related to queue operations.

Methods available in eqs_client

Change VisibilityTimeout

Request Syntax

$result = $eqs_client->changeMessageVisibility([
        'QueueUrl' => 'QUEUE_URL',
        'ReceiptHandle' => 'RECEIPT_HANDLE',
        'VisibilityTimeout' => 123,
]);

Parameters

QueueUrl (string)- [Required]

The URL of the E2E EQS queue whose message’s visibility is changed.

ReceiptHandle (string) - [Required]

The receipt handle is associated with the message whose visibility timeout is changed. This parameter is returned by the ReceiveMessage action

VisibilityTimeout (integer) - [Required]

The new value for the message’s visibility timeout (in seconds)

Response Syntax

null

Change VisibilityTimeout in batch

$result = $eqs_client->changeMessageVisibilityBatch([
  'QueueUrl' => 'QUEUE_URL',
  'Entries' => [
        [
          'Id' => 'MESSAGE_ID_1',
          'ReceiptHandle' => 'RECEIPT_HANDLE_1',
          'VisibilityTimeout' => 123,
        ],
        [
          'Id' => 'MESSAGE_ID_2',
          'ReceiptHandle' => 'RECEIPT_HANDLE_2',
      'VisibilityTimeout' => 456,
        ],
  ],
]);

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue whose message’s visibility is changed.

Entries (Array) - [Required]

(Associative Array)

id [Required]-(string) An identifier for this particular receipt handle used to communicate the result

ReceiptHandle [Required] -(string) A receipt handle

VisibilityTimeout - (string) The new value (in seconds) for the message’s visibility timeout

Response Syntax

[
  'Failed' => [
        [
          'Code' => '<string>',
          'Id' => '<string>',
          'Message' => '<string>',
          'SenderFault' => true || false,
        ],
        // ...
  ],
  'Successful' => [
        [
          'Id' => '<string>',
        ],
        // ...
  ],
]

Create queue

Request Syntax

$params = [
  'QueueName' => 'my-queue',
  'Attributes' => [
        'DelaySeconds' => '0',
        'MaximumMessageSize' => '262144',
        'MessageRetentionPeriod' => '345600',
        'ReceiveMessageWaitTimeSeconds' => '0',
        'VisibilityTimeout' => '30',
  ],
  'tags' => [
        'Department' => 'Finance',
  ],
];

// Create the queue
$result = $eqs_client->createQueue($params);

Parameters

QueueName (string)- [Required]

1 - A queue name can have up to 80 characters

2 - Valid values: alphanumeric characters, hyphens ( -), and underscores ( _).

Attributes (associative array)- Attributes could be

1 - DelaySeconds - Time(second), to which extent delivery of messages is delayed in the queue

Valid values - 0 to 900 (second)

default - 0 (second)

2 - MaximumMessageSize - The size of the message after which the queue will reject the message

Valid values - 1,024 bytes (1 KiB) to 262,144 bytes (256 KiB)

default - 262,144 bytes(256 KiB)

3 - MessageRetentionPeriod - Time to which extent a queue will retain a message

Valid values - 60 seconds (1 minute) to 1,209,600 seconds (14 days)

default - 345,600 (4 days)

4 - ReceiveMessageWaitTimeSeconds - Time to which extent ReceiveMessage action waits before receiving a message

Valid values - 0 to 20 (seconds)

default - 0 (second)

5 - VisibilityTimeout - The amount of time that a message in a queue is invisible to other consumers after a consumer retrieves it.

Valid values - 0 to 43,200 seconds (12 hours)

default - 30 second

tags (associative array) -

1 - Adding more than 50 tags to a queue isn’t recommended.

2 - A new tag with a key identical to that of an existing tag overwrites the existing tag.

Response Syntax

{ 'QueueUrl': 'string' }

Delete message

Request Syntax

$eqs_client->deleteMessage([
        'QueueUrl' => 'QUEUE_URL',
        'ReceiptHandle' => 'RECEIPT_HANDLE',
]);

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which messages are deleted.

ReceiptHandle (string) - [Required]

The receipt handle is associated with the message to delete.

Response Syntax

null

Delete message in batch

Request Syntax

$result = $eqs_client->deleteMessageBatch([
  'QueueUrl' => 'QUEUE_URL',
  'Entries' => [
        [
          'Id' => 'MESSAGE_ID_1',
          'ReceiptHandle' => 'RECEIPT_HANDLE_1',
        ],
        [
          'Id' => 'MESSAGE_ID_2',
          'ReceiptHandle' => 'RECEIPT_HANDLE_2',
        ]
  ]
]);

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which messages are deleted.

Entries (Array) - [Required]

(associative array) id [Required]-(string) An identifier for this particular receipt handle used to communicate the result ReceiptHandle [Required] -(string) A receipt handle

Response Syntax

[
  'Successful' => [
        [
          'Id' => 'string',
        ],
        // Additional successful entries
  ],
  'Failed' => [
        [
          'Id' => 'string',
          'SenderFault' => true || false,
      'Code' => 'string',
          'Message' => 'string',
        ],
        // Additional failed entries
  ],
]

Delete queue

Request Syntax

$result = $eqs_client->deleteQueue(array(
        // QueueUrl is required
        'QueueUrl' => 'string',
));

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue to delete.

Response Syntax

null

Get queue attributes

Request Syntax

$params = [
        'QueueUrl' => 'QUEUE_URL',
        'AttributeNames' => ['All'], // Or specify specific attributes as an array
];

// Call the operation
$result = $sqsClient->getQueueAttributes($params);

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which attributes are get.

AttributeNames (Array) - [Optional]

A list of attributes for which to retrieve information

All - it specifies, returns all values

you can also specify specific attributes in the list

As - [‘VisibilityTimeout’ , ‘MaximumMessageSize’ , ‘MessageRetentionPeriod’ , ‘ApproximateNumberOfMessages’ ,’ApproximateNumberOfMessagesNotVisible’ , ‘CreatedTimestamp’ , ‘LastModifiedTimestamp’ , ‘QueueArn’ , ‘ApproximateNumberOfMessagesDelayed’ , ‘DelaySeconds’ , ‘ReceiveMessageWaitTimeSeconds’]

Response Syntax

[
  'Attributes' => ['<string>', ...],
]

Get queue url

Request Syntax

$result = $eqs_client->getQueueUrl([
        'QueueName' => '<string>', // REQUIRED
]);

Parameters

QueueName (string) -[Required]

The name of the queue whose URL must be fetched.

Response Syntax

[
  'QueueUrl' => '<string>',
]

List queue tags

Request Syntax

$result = $eqs_client->listQueueTags([
        'QueueUrl' => 'string',
]);

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue of which all the tags must be listed.

Response Syntax

[
  'Tags' => ['<string>', ...],
]

List queues

Request Syntax

$result = $eqs_client->listQueues([
        'MaxResults' => <integer>,
        'NextToken' => '<string>',
        'QueueNamePrefix' => '<string>',
]);
Parameters
QueueNamePrefix (string) - [Optional]

A string to use for filtering the list results. Only those queues whose name begins with the specified string are returned.

**NextToken**(string) -

Pagination token to request the next set of results.

MaxResults (integer) - [Optional]

The maximum number of results to include in the response. Valid values - 1 to 1000

Response Syntax

[
  'NextToken' => '<string>',
  'QueueUrls' => ['<string>', ...],
]

Purge queue

delete all the messages from queue.

Request Syntax

$result = $eqs_client->purgeQueue([
  'QueueUrl' => '<string>', // REQUIRED
]);

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue of which all the messages must be deleted.

Response Syntax

null

Receive message

$result = $eqs_client->receiveMessage([
        'AttributeNames' => ['<string>', ...],
        'MaxNumberOfMessages' => <integer>,
        'MessageAttributeNames' => ['<string>', ...],
        'QueueUrl' => '<string>', // REQUIRED
        'ReceiveRequestAttemptId' => '<string>',
        'VisibilityTimeout' => <integer>,
        'WaitTimeSeconds' => <integer>,
]);

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue from which messages are received.

AttributeNames (Array) -

A list of attributes that need to be returned along with each message.

All - it specifies, returns all values

you can also specify specific attributes in the list

As - [‘VisibilityTimeout’ , ‘MaximumMessageSize’ , ‘MessageRetentionPeriod’ , ‘ApproximateNumberOfMessages’ ,’ApproximateNumberOfMessagesNotVisible’ , ‘CreatedTimestamp’ , ‘LastModifiedTimestamp’ , ‘QueueArn’ , ‘ApproximateNumberOfMessagesDelayed’ , ‘DelaySeconds’ , ‘ReceiveMessageWaitTimeSeconds’]

MessageAttributeNames (Array) -

The name of the message attribute.

MaxNumberOfMessages (integer) -

The maximum number of messages to return.

Valid range - 1 to 10

default - 1

VisibilityTimeout (integer) -

The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request.

WaitTimeSeconds (integer) -

The duration (in seconds) for which the call waits for a message to arrive in the queue before returning.

Response Syntax

[
  'Messages' => [
        [
          'Attributes' => ['<string>', ...],
          'Body' => '<string>',
          'MD5OfBody' => '<string>',
          'MD5OfMessageAttributes' => '<string>',
          'MessageAttributes' => [
                '<String>' => [
                  'BinaryListValues' => [<string || resource || Psr\Http\Message\StreamInterface>, ...],
              'BinaryValue' => <string || resource || Psr\Http\Message\StreamInterface>,
                  'DataType' => '<string>',
                  'StringListValues' => ['<string>', ...],
                  'StringValue' => '<string>',
                ],
                // ...
          ],
          'MessageId' => '<string>',
          'ReceiptHandle' => '<string>',
        ],
        // ...
  ],
]

Send message

Request Syntax

$result = $eqs_client->sendMessage([
  'DelaySeconds' => <integer>,
  'MessageAttributes' => [
        '<String>' => [
          'DataType' => '<string>', // REQUIRED
          'StringListValues' => ['<string>', ...],
          'StringValue' => '<string>',
        ],
        // ...
  ],
  'MessageBody' => '<string>', // REQUIRED
  'MessageDeduplicationId' => '<string>',
  'MessageGroupId' => '<string>',
  'MessageSystemAttributes' => [
        '<MessageSystemAttributeNameForSends>' => [
          'DataType' => '<string>', // REQUIRED
          'StringListValues' => ['<string>', ...],
          'StringValue' => '<string>',
        ],
        // ...
  ],
  'QueueUrl' => '<string>', // REQUIRED
]);

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue to which messages are send.

MessageBody (string) - [Required]

The message to send. The minimum size is one character. The maximum size is 256 KB.

DelaySeconds (integer) -

The length of time, in seconds, for which to delay a specific message.

MessageAttributes (associative array) -

Each message attribute consists of a Name, Type, and Value .

Name, type, value and the message body must not be empty or null .

(string) - name of the message attributes

(associative array) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data,

encrypted data, or images.

(string) - [Required] Type of message attributes

EQS support the following data type

Binary, Number, String

MessageSystemAttributes (associative array) -

Each message system attribute consists of a Name, Type, and Value.

The name, type, value and message body must not be empty or null.

(string) - the name of the message attributes

(associative array) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data,

encrypted data, or images.

(string) - Type of message attributes

EQS support the following data type

Binary , Number , String

Response Syntax

[
  'MD5OfMessageAttributes' => '<string>',
  'MD5OfMessageBody' => '<string>',
  'MD5OfMessageSystemAttributes' => '<string>',
  'MessageId' => '<string>',
  'SequenceNumber' => '<string>',
]

Send message in batch

Request Syntax

$result = $eqs_client->sendMessageBatch([
  'Entries' => [ // REQUIRED
        [
          'DelaySeconds' => <integer>,
          'Id' => '<string>', // REQUIRED
          'MessageAttributes' => [
                '<String>' => [
                  'DataType' => '<string>', // REQUIRED
                  'StringListValues' => ['<string>', ...],
                  'StringValue' => '<string>',
                ],
                // ...
          ],
          'MessageBody' => '<string>', // REQUIRED
          'MessageDeduplicationId' => '<string>',
          'MessageGroupId' => '<string>',
          'MessageSystemAttributes' => [
                '<MessageSystemAttributeNameForSends>' => [
                  'DataType' => '<string>', // REQUIRED
                  'StringListValues' => ['<string>', ...],
                  'StringValue' => '<string>',
                ],
                // ...
          ],
        ],
        // ...
  ],
  'QueueUrl' => '<string>', // REQUIRED
]);

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue to which messages are sent.

Entries (Array) - [Required]

A list of SendMessageBatchRequestEntry items.

(Associative array) -

Contains the details of a single E2E EQS message along with an Id.

Id (string) - [REQUIRED]

An identifier for a message in this batch is used to communicate the result.

MessageBody (string) - [Required]

The message to send. The minimum size is one character. The maximum size is 256 KB.

DelaySeconds (integer) -

The length of time, in seconds, for which to delay a specific message.

MessageAttributes (associative array) -

Each message attribute consists of a Name, Type, and Value.

The Name, type, value and message body must not be empty or null.

(string) - The name of the message attributes

(associative array) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data, encrypted data, or images.

(string) -[Required] Type of message attributes

EQS support the following data type

Binary, Number, String

MessageSystemAttributes (associative array) -

Each message system attribute consists of a Name, Type, and Value.

Name, type, value and the message body must not be empty or null.

(string) - The name of the message attributes

(associative array) - Value of message attributes

1 - StringValue (string) - Strings are Unicode with UTF-8 binary encoding.

2 - BinaryValue (bytes) - Binary type attributes can store any binary data, such as compressed data,

encrypted data, or images.

(string) - Type of message attributes

EQS support following data type

Binary , Number , String

Response Syntax

[
  'Failed' => [
        [
          'Code' => '<string>',
          'Id' => '<string>',
          'Message' => '<string>',
          'SenderFault' => true || false,
        ],
        // ...
  ],
  'Successful' => [
        [
          'Id' => '<string>',
          'MD5OfMessageAttributes' => '<string>',
          'MD5OfMessageBody' => '<string>',
          'MD5OfMessageSystemAttributes' => '<string>',
          'MessageId' => '<string>',
          'SequenceNumber' => '<string>',
        ],
        // ...
  ],
]

Tag queue

Request Syntax

$result = $eqs_client->tagQueue([
   'QueueUrl' => '<string>', // REQUIRED
   'Tags' => ['<string>', ...], // REQUIRED
]);

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue.

Tags (associative array) - [Required]

The list of tags to be added to the specified queue.

Response Syntax

null

Untag queue

Request Syntax

$result = $eqs_client->untagQueue([
   'QueueUrl' => '<string>', // REQUIRED
   'TagKeys' => ['<string>', ...], // REQUIRED
]);

Parameters

QueueUrl (string) - [Required]

The URL of the E2E EQS queue.

TagKeys (Array) - [Required]

The list of tags to be removed from the specified queue.

Response Syntax

null