Amazon SQS Source Connector for Confluent Cloud¶
The Kafka Connect Amazon Simple Queue Service (SQS) Source connector 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.
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.
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.
Important
If you are still on Confluent Cloud Enterprise, please contact your Confluent Account Executive for more information about using this connector.
Features¶
The Amazon SQS Source connector provides the following features:
- 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 Configuration Properties for configuration property values and descriptions.
See Cloud connector limitations for additional 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
- Authorized access to a Confluent Cloud cluster on Amazon Web Services (AWS), Microsoft Azure (Azure), or Google Cloud Platform (GCP).
- The Confluent Cloud CLI installed and configured for the cluster. See Install and Configure the Confluent Cloud CLI.
- For networking considerations, see Internet access to resources. To use static egress IPs, see Static Egress IP Addresses.
- An AWS account configured with Access Keys. You use these access keys when setting up the connector.
- Amazon SQS connection details. For more information, see Setting up Amazon SQS.
- A topic must exist before launching the connector.
Using the Confluent Cloud Console¶
Step 1: Launch your Confluent Cloud cluster.¶
See the Quick Start for Apache Kafka using Confluent Cloud for installation instructions.
Step 2: Add a connector.¶
Click Connectors. If you already have connectors in your cluster, click Add connector.
Step 4: Set up the connection.¶
Note
- Make sure you have all your prerequisites completed.
- An asterisk ( * ) designates a required entry.
- Enter a connector Name.
- Enter your Kafka Cluster credentials. The credentials are either the cluster API key and secret or the service account API key and secret.
- Select a topic. A topic must exist before launching the connector.
- Enter your AWS credentials. For information about how to set these up, see Access Keys.
- Enter the Amazon SQS connection details:
- Fully qualified 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 left empty, the connector attempts to infer the region from the SQS URL.
- Fully qualified SQS URL: For example,
- Select an Output message 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).
- Enter the number of tasks to use with the connector. More tasks may improve performance.
See Configuration Properties for configuration property values and descriptions.
Step 5: Launch the connector.¶
Verify the connection details and click Launch.
Step 6: Check the connector status.¶
The status for the connector should go from Provisioning to Running.
Step 7: 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 Connect section.
Using the Confluent Cloud CLI¶
Complete the following steps to set up and run the connector using the Confluent Cloud CLI.
Note
Make sure you have all your prerequisites completed.
Step 1: List the available connectors.¶
Enter the following command to list available connectors:
ccloud connector-catalog list
Step 2: Show the required connector configuration properties.¶
Enter the following command to show the required connector properties:
ccloud connector-catalog describe <connector-catalog-name>
For example:
ccloud connector-catalog describe SqsSource
Example output:
Following are the required configs:
connector.class: SqsSource
name
kafka.api.key
kafka.api.secret
sqs.url
kafka.topic
aws.access.key.id
aws.secret.key.id
output.data.format
tasks.max
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.api.key": "<INSERT KAFKA API KEY>",
"kafka.api.secret": "<INSERT 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.access.key": "<INSERT AWS API SECRET>",
"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."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.access.key"
: Enter the AWS Access Key ID and Secret. 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)."tasks.max"
: Enter the number of tasks to use with the connector. More tasks may improve performance.
See Configuration Properties for configuration 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:
ccloud connector create --config <file-name>.json
For example:
ccloud connector create --config 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:
ccloud connector 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 Connect section.
Configuration Properties¶
The following connector configuration properties are used with the Amazon SQS Source connector for Confluent Cloud.
aws.access.key.id
The AWS access key that is used to connect to SQS.
- Type: password
- Default: null
- Importance: high
aws.secret.key.id
The AWS secret key that is used to connect to SQS.
- Type: password
- Default: null
- Importance: high
sqs.url
Fully qualified Amazon SQS URL from which this source connector polls messages.
- Type: string
- Valid Values: Fully qualified HTTPS URL. For example:
https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue
. - Importance: high
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.
- Type: string
- Importance: medium
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¶
See also
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 Cloud CLI to manage your resources in Confluent Cloud.