Contact Us 1-800-596-4880

Amazon SQS Connector 5.10 Additional Configuration Information - Mule 4

Configure additional functionality such as controlling polling behavior globally and locally, receiving messages on the primary node only, creating the FIFO queue, and managing large payloads.

Control Polling Behavior

Since version 5.9, the default behavior of the Receive Messages source and the Read operation is to use long polling:

  • With long polling, SQS Connector returns the query results as soon as possible, if any messages are present.

    Otherwise, SQS Connector waits the specified amount of seconds before returning an empty response.

  • With short polling, SQS Connector always returns the query results as soon as possible, even if that means returning an empty response.

Long polling can reduce the number of network requests without affecting the throughput.

You can control polling behavior either globally or at the individual source and operation level.

Control Polling Behavior Globally

To control polling behavior globally, use the Default Wait Time field on the Advanced tab of the global element configuration screen for the Receive Messages source, Read operation, or both:

  • Set this field to a value between 1 and 20 to use long polling. With long polling, if there are messages available immediately, the connector returns the query results immediately. If not, the connector waits up to the specified amount of seconds for a message to be added before returning an empty response.

  • Set this field to 0 to use short polling. With short polling, the connector always returns the query results as soon as possible, even if that means returning an empty response.

In the following screenshot, the Default Wait Time field is set to 20. This value directs the connector to use long polling and to wait 20 seconds before returning an empty response.

Default Wait Time Configuration

Control Polling Behavior Locally

To control polling behavior locally, use the Wait Time field on the Advanced tab of the Receive Messages source properties window, the Read operation properties window, or both.

Receive Messages on the Primary Node Only

The default behavior of the Receive Messages source is to receive messages on all nodes when running in cluster mode.

If you want the app to receive messages on the primary node only:

  1. In Studio, select the Receive Messages source for your flow.

  2. On the Advanced sub-tab of the Receive messages tab, select the Primary node only checkbox:

    Read message configuration Advanced tab with Primary node only option selected

The multi-node cluster behavior depends on the selected SQS queue type. When using the Standard queue, SQS guarantees that a message is delivered at least once. However, duplicate messages might be introduced in the queue. To avoid duplication of messages in the queue, you can use a FIFO (First-In-First-Out) queue to ensure that a message is delivered only once and that it remains available until a consumer processes and deletes it.

For more information about queue types, see AWS SQS Standard Queues and AWS SQS FIFO Queues.

Create the FIFO Queue

FIFO queues deliver messages in the order in which they are sent.

To create the FIFO queue, use the Create queue operation in the connector, and set the FifoQueue and ContentBasedDeduplication field values to true.

End the queue name value with the .fifo extension, for example:
MyTestFIFOQueue.fifo.

When you create the FIFO queues, select any of the 15 regions that Amazon supports.

When you use Amazon SQS Connector to send messages to the FIFO queue, use the same queue URL and region name that you used when creating the FIFO queue. You must also provide a value for the attribute message group id in the connector configuration while sending messages.

Manage Large Payloads

To enable support for managing large message payloads in Amazon SQS Connector, follow these steps:

  1. In Studio, click the Global Elements tab at the base of the canvas.

  2. Select the Amazon SQS Configuration you previously created and click Edit.

  3. In the Connection section, click the Advanced tab.

  4. In the Large Payload Support field, choose either:

    • Expression or Bean Reference

    • Edit Inline

      Configure Large Payload Support
  5. Configure the parameters as follows:

    Field Description

    Bucket

    Name of the bucket to use for storing large message payloads. The bucket must already be created and configured in AWS S3. Enabling this feature incurs additional charges for using AWS S3.

    Message Size Threshold

    Message size threshold value for storing message payloads in the AWS S3 bucket. The default value for message size threshold is 256 KB and the maximum threshold size value is 256KB. The maximum message size is 2GB.

    Message Size Threshold Unit

    Represents the data unit for the message size threshold.

    After you specify the values for these fields, Amazon SQS Connector is ready to manage large payload messages and store them automatically in the specified AWS S3 bucket when the message size threshold value is exceeded.

For an example of sending and receiving messages with large payload messages, see Send and Receive Large Messages Example.

Next

After you create the FIFO queue, you can try the Amazon SQS Connector Examples.

View on GitHub