Amazon SQS Source Connector for Confluent Cloud

The fully-managed Amazon Simple Queue Service (SQS) Source connector for Confluent Cloud is used to move messages from an Amazon SQS Queue into Apache Kafka®. It supports both Standard queues and First-In-First-Out (FIFO) queues. The connector polls an Amazon SQS queue, converts SQS messages into Kafka records, and then pushes the records into a Kafka topic.

Note

This is a Quick Start for the fully-managed cloud connector. If you are installing the connector locally for Confluent Platform, see Amazon SQS Source Connector for Confluent Platform.

The connector converts an Amazon SQS message into a Kafka record, with the following structure:

  • The key encodes the SQS queue name and message ID in a struct. For FIFO queues, it also includes the message group ID.
  • The value encodes the body of the SQS message and various message attributes in a struct.
  • Each header encodes message attributes that may be present in the SQS message.

For record schema details, see Record Schemas.

For standard queues, the connector supports best-effort ordering guarantees. This means that there is a chance records will end up in a different order in Kafka.

For FIFO queues, the connector guarantees records are inserted into Kafka in the order they were inserted in Amazon SQS, as long as the destination Kafka topic has exactly one partition. If the destination topic has more than one partition, you can use a Single Message Transforms (SMT) to set the partition based on the MessageGroupId field in the key.

Note that the connector provides least once delivery. This means there is a chance that the connector can introduce duplicate records in Kafka for both standard and FIFO queues.

Features

The Amazon SQS Source connector provides the following features:

  • Topics created automatically: The connector can automatically create Kafka topics.
  • At least once delivery: The connector guarantees that records are delivered at least once to the Kafka topic.
  • Supports multiple tasks: The connector supports running one or more tasks. More tasks may improve performance.
  • Automatic retries: The connector will retry all requests (that can be retried) when the Amazon SQS service is unavailable. This value defaults to three retries.
  • Supported data formats: The connector supports Avro, JSON Schema (JSON-SR), Protobuf, and JSON (schemaless) output formats. Schema Registry must be enabled to use a Schema Registry-based format (for example, Avro, JSON Schema, or Protobuf). See Schema Registry Enabled Environments for additional information.

For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Managed and Custom Connectors section.

Limitations

Be sure to review the following information.

Quick Start

Use this quick start to get up and running with the Confluent Cloud Amazon SQS Source connector. The quick start provides the basics of selecting the connector and configuring it to stream events.

Prerequisites

Using the Confluent Cloud Console

Step 1: Launch your Confluent Cloud cluster

See the Quick Start for Confluent Cloud for installation instructions.

Step 2: Add a connector

In the left navigation menu, click Connectors. If you already have connectors in your cluster, click + Add connector.

Step 3: Select your connector

Click the Amazon SQS Source connector card.

Amazon SQS Source Connector Card

Step 4: Enter the connector details

Note

  • Make sure you have all your prerequisites completed.
  • An asterisk ( * ) designates a required entry.

At the Add Amazon SQS Source Connector screen, complete the following:

Select the topic you want to send data to from the Topics list. To create a new topic, click +Add new topic.

Step 5: Check for records

Verify that records are being produced at the Kafka topic.

For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Managed and Custom Connectors section.

Using the Confluent CLI

Complete the following steps to set up and run the connector using the Confluent CLI.

Note

Make sure you have all your prerequisites completed.

Step 1: List the available connectors

Enter the following command to list available connectors:

confluent connect plugin list

Step 2: List the connector configuration properties

Enter the following command to show the connector configuration properties:

confluent connect plugin describe <connector-plugin-name>

The command output shows the required and optional configuration properties.

Step 3: Create the connector configuration file

Create a JSON file that contains the connector configuration properties. The following entry shows the required configuration properties.

{
  "name": "SqsSource_0",
  "config": {
    "connector.class": "SqsSource",
    "name": "SqsSource_0",
    "kafka.auth.mode": "KAFKA_API_KEY",
    "kafka.api.key": "<my-kafka-api-key>",
    "kafka.api.secret": "<my-kafka-api-secret>",
    "sqs.url": "https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue",
    "kafka.topic": "stocks",
    "aws.access.key.id": "<INSERT AWS API KEY>",
    "aws.secret.key.id": "<INSERT AWS API SECRET KEY ID>",
    "output.data.format": "JSON",
    "tasks.max": "1"
  }
}

Note the following property definitions:

  • "connector.class": Identifies the connector plugin name.
  • "name": Sets a name for your new connector.
  • "kafka.auth.mode": Identifies the connector authentication mode you want to use. There are two options: SERVICE_ACCOUNT or KAFKA_API_KEY (the default). To use an API key and secret, specify the configuration properties kafka.api.key and kafka.api.secret, as shown in the example configuration (above). To use a service account, specify the Resource ID in the property kafka.service.account.id=<service-account-resource-ID>. To list the available service account resource IDs, use the following command:

    confluent iam service-account list
    

    For example:

    confluent iam service-account list
    
       Id     | Resource ID |       Name        |    Description
    +---------+-------------+-------------------+-------------------
       123456 | sa-l1r23m   | sa-1              | Service account 1
       789101 | sa-l4d56p   | sa-2              | Service account 2
    
  • "sqs.url": For example, https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue. For details, see Amazon SQS queue and message identifiers.

  • "sqs.region": The AWS region that the SQS queue belongs to. If this property is not used, the connector attempts to infer the region from the SQS URL.

  • "aws.access.key.id" and "aws.secret.key.id": Enter the AWS Access Key ID and Secret Key ID. For information about how to set these up, see Access Keys.

  • "output.data.format": Enter an output data format (data going to the Kafka topic): AVRO, JSON_SR (JSON Schema), PROTOBUF, or JSON (schemaless). Schema Registry must be enabled to use a Schema Registry-based format (for example, Avro, JSON_SR (JSON Schema), or Protobuf). See Schema Registry Enabled Environments for additional information.

  • "tasks.max": Enter the number of tasks to use with the connector. More tasks may improve performance.

Single Message Transforms: See the Single Message Transforms (SMT) documentation for details about adding SMTs using the CLI.

See Configuration Properties for all property values and descriptions.

Step 4: Load the properties file and create the connector

Enter the following command to load the configuration and start the connector:

confluent connect cluster create --config-file <file-name>.json

For example:

confluent connect cluster create --config-file sqs-source-config.json

Example output:

Created connector SqsSource_0 lcc-do6vzd

Step 5: Check the connector status

Enter the following command to check the connector status:

confluent connect cluster list

Example output:

ID           |       Name       | Status  | Type   | Trace
+------------+------------------+---------+--------+-------+
lcc-do6vzd   | SqsSource_0      | RUNNING | source |       |

Step 6: Check for records.

Verify that records are being produced at the Kafka topic.

For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Managed and Custom Connectors section.

Configuration Properties

Use the following configuration properties with the fully-managed connector. For self-managed connector property definitions and other details, see the connector docs in Self-managed connectors for Confluent Platform.

How should we connect to your data?

name

Sets a name for your connector.

  • Type: string
  • Valid Values: A string at most 64 characters long
  • Importance: high

Kafka Cluster credentials

kafka.auth.mode

Kafka Authentication mode. It can be one of KAFKA_API_KEY or SERVICE_ACCOUNT. It defaults to KAFKA_API_KEY mode.

  • Type: string
  • Default: KAFKA_API_KEY
  • Valid Values: KAFKA_API_KEY, SERVICE_ACCOUNT
  • Importance: high
kafka.api.key

Kafka API Key. Required when kafka.auth.mode==KAFKA_API_KEY.

  • Type: password
  • Importance: high
kafka.service.account.id

The Service Account that will be used to generate the API keys to communicate with Kafka Cluster.

  • Type: string
  • Importance: high
kafka.api.secret

Secret associated with Kafka API key. Required when kafka.auth.mode==KAFKA_API_KEY.

  • Type: password
  • Importance: high

Which topic do you want to send data to?

kafka.topic

Identifies the topic name to write the data to.

  • Type: string
  • Importance: high

Schema Config

schema.context.name

Add a schema context name. A schema context represents an independent scope in Schema Registry. It is a separate sub-schema tied to topics in different Kafka clusters that share the same Schema Registry instance. If not used, the connector uses the default schema configured for Schema Registry in your Confluent Cloud environment.

  • Type: string
  • Default: default
  • Importance: medium

AWS Credentials

aws.access.key.id

The Amazon Access Key used to connect to SQS.

  • Type: password
  • Importance: high
aws.secret.key.id

The Amazon Secret Key used to connect to SQS.

  • Type: password
  • Importance: high

How should we connect to Amazon SQS?

sqs.url

Fully qualified Amazon SQS URL to read messages from

  • Type: string
  • Importance: high
sqs.region

The AWS region that the SQS queue belongs to. If left empty, the connector will attempt to infer the region from the SQS URL.

  • Type: string
  • Importance: medium

Output messages

output.data.format

Sets the output Kafka record value format. Valid entries are AVRO, JSON_SR, PROTOBUF, or JSON. Note that you need to have Confluent Cloud Schema Registry configured if using a schema-based message format like AVRO, JSON_SR, and PROTOBUF

  • Type: string
  • Importance: high

Number of tasks for this connector

tasks.max

Maximum number of tasks for the connector.

  • Type: int
  • Valid Values: [1,…]
  • Importance: high

Record Schemas

The Amazon SQS Source connector creates records using following schemas.

Key Schema

The Key is a struct with the following fields:

Field Name Schema Type Optional? Description
QueueUrl string mandatory The fully qualified SQS queue URL from which the record is generated.
MessageId string mandatory The unique message ID of the message within Amazon SQS.
MessageGroupId string optional For FIFO queues, this is the message group ID.

Value Schema

The Value is a struct with the following fields:

Field Name Schema Type Optional? Description
Body string   The body of the SQS message.
ApproximateFirstReceiveTimestamp int64   Returns the time the message was first received from the queue (epoch time in milliseconds).
ApproximateReceiveCount int32   Returns the number of times a message has been received across all queues but not deleted.
SenderId string   The IAM user or role that sent this message to SQS.
SentTimestamp int64   Returns the time the message was sent to the queue (epoch time in milliseconds
MessageDeduplicationId string Optional Returns the value provided by the producer that calls the SendMessage action.
MessageGroupId string Optional Returns the value provided by the producer that calls the SendMessage action. Messages with the same MessageGroupId are returned in sequence.
SequenceNumber string   Returns the value provided by Amazon SQS.

For more information, see Request Parameters.

Header Schema

Each message attribute in SQS is converted to a Header in Kafka.

  • The header key is the name of the message attribute.
  • The header value is the value of the message attribute.
  • The header schema depends on the data type of the message attribute.
    • String message attributes use a string schema.
    • Number message attributes use a string schema.
    • Binary message attributes use a bytes schema.
    • Custom message attributes use either string or bytes, depending on the type of custom attribute.

For more information, see Message attribute components.

Next Steps

For an example that shows fully-managed Confluent Cloud connectors in action with Confluent Cloud ksqlDB, see the Cloud ETL Demo. This example also shows how to use Confluent CLI to manage your resources in Confluent Cloud.

../_images/topology.png