<a id="cc-google-pubsub-source"></a>

# Google Cloud Pub/Sub Source Connector for Confluent Cloud

The fully managed Google Cloud Pub/Sub Source connector for Confluent Cloud captures a snapshot of the existing data in a pub/sub database, then
monitors and records all subsequent row-level changes. All of the events for each table
are recorded in a separate Apache Kafka® topic. The events can then be easily consumed
by applications and services. Note that deleted records are not captured.

Confluent Cloud is available through [Google Cloud Marketplace](https://console.cloud.google.com/marketplace/product/confluent-prod/apache-kafka-on-confluent-cloud?inv=1&invt=Ab2Ryw)
or [directly from Confluent](https://www.confluent.io/get-started/).

#### NOTE
This is a Quick Start for the fully managed cloud connector. If you are
installing the connector locally for Confluent Platform, see [Google Cloud Pub/Sub Source
Connector for Confluent Platform](https://docs.confluent.io/kafka-connectors/gcp-pubsub/current/).

## Features

The Google Cloud Pub/Sub Source connector provides the following features:

* **Topics created automatically**: The connector can automatically create Kafka topics.
* **Provider integration support**: The connector supports Google Cloud’s native identity authorization
  using Confluent Provider Integration. For more information about provider integration setup,
  see the [connector authentication](#cc-google-pubsub-source-setup-connection).
* **Fetches records** from a Pub/Sub topic through a subscription.
* **Select configuration properties**:
  - `gcp.pubsub.max.retry.time=5`
  - `gcp.pubsub.message.max.count=10000`

For more information and examples to use with the Confluent Cloud API for Connect,
see the [Confluent Cloud API for Connect Usage Examples](connect-api-section.md#ccloud-connect-api) section.

## Limitations

Be sure to review the following information.

* For connector limitations, see [Google Pub/Sub Source Connector](limits.md#google-pubsub-source-limits) limitations.
* If you plan to use one or more Single Message Transformations (SMTs), see [SMT Limitations](single-message-transforms.md#cc-single-message-transforms-limitations).

## Quick Start

Use this quick start to get up and running with the Google Cloud Pub/Sub source
connector. The quick start provides the basics of selecting the connector and
configuring it to obtain a snapshot of the existing data in a Pub/Sub database
and then monitoring and recording all subsequent row-level changes.

<a id="cc-google-pubsub-source-prereqs"></a>

Prerequisites
: - Authorized access to a [Confluent Cloud](https://www.confluent.io/confluent-cloud/) cluster on Amazon Web Services (AWS), Microsoft Azure (Azure), or Google Cloud.
  - A [Google Cloud Pub/Sub](https://cloud.google.com/pubsub/docs/subscriber) subscription and topic.
  - A Google Cloud [service account](https://cloud.google.com/iam/docs/creating-managing-service-accounts). You download service account [credentials as a JSON file](https://cloud.google.com/iam/docs/creating-managing-service-account-keys). These credentials are used when setting up the connector configuration.
  - The Google Cloud Pub/Sub Source connector must be granted `roles/pubsub.subscriber` and `roles/pubsub.viewer` in Google Cloud for it to start. See the [list of Pub/Sub IAM roles](https://cloud.google.com/pubsub/docs/access-control#roles) for more information.
  - For networking considerations, see [Networking and DNS](overview.md#connect-internet-access-resources). To use a set of public egress IP addresses, see [Public Egress IP Addresses for Confluent Cloud Connectors](static-egress-ip.md#cc-static-egress-ips).
  - The Confluent CLI installed and configured for the cluster. See [Install and Configure the Confluent CLI](https://docs.confluent.io/confluent-cli/current/install.html).
  <br/>
  - Kafka cluster credentials. The following lists the different ways you can provide credentials.
    - Enter an existing [service account](service-account.md#s3-cloud-service-account) resource ID.
    - Create a Confluent Cloud [service account](service-account.md#s3-cloud-service-account) for the connector. Make sure to review the ACL entries required in the [service account documentation](service-account.md#s3-cloud-service-account). Some connectors have specific ACL requirements.
    - Create a Confluent Cloud API key and secret. To create a key and secret, you can use [confluent api-key create](https://docs.confluent.io/confluent-cli/current/command-reference/api-key/confluent_api-key_create.html) *or* you can autogenerate the API key and secret directly in the Cloud Console when setting up the connector.

### Using the Confluent Cloud Console

#### Step 1: Launch your Confluent Cloud cluster

To create and launch a Kafka cluster in Confluent Cloud, see [Create a kafka cluster in Confluent Cloud](../get-started/index.md#cloud-create-kafka-cluster).

#### 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 **Google Cloud Pub/Sub Source** connector card.

![Google Cloud Pub/Sub Source Connector Card](images/ccloud-googlepubsub-source-icon.png)

<a id="cc-google-pubsub-source-setup-connection"></a>

#### Step 4: Enter the connector details

#### NOTE
* Make sure you have all your [prerequisites](#cc-google-pubsub-source-prereqs) completed.
* An asterisk ( \* ) designates a required entry.

At the **Add Google Cloud Pub/Sub Source Connector** screen, complete the
following:

### Topic selection

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

### Kafka access

1. Select the way you want to provide **Kafka Cluster credentials**. You can
   choose one of the following options:
   - **My account**: This setting allows your connector to globally access everything
     that you have access to. With a user account, the connector uses an API key and
     secret to access the Kafka cluster. This option is not recommended for production.
   - **Service account**: This setting limits the access for your connector by using a
     [service account](service-account.md#s3-cloud-service-account). This option is recommended for
     production.
   - **Use an existing API key**: This setting allows you to specify an API key and a
     secret pair. You can use an existing pair or create a new one. This method is not
     recommended for production environments.

   #### NOTE
   Freight clusters support only service accounts for Kafka authentication.
2. Click **Continue**.

### Authentication

1. Configure the authentication properties:

   **GCP credentials**
   - **Authentication method**: Under **GCP credentials**, select one of the following authenticatation menthods with GCP:
     - **Google Cloud service account**
     - **Google service account impersonation**
   - **Provider Integration**: If you select **Google service account impersonation**, choose an existing integration name
     under **Provider integration name** dropdown that has access to your resource or create a
     new provider integration. For more information, see [Manage a Google Cloud Provider Integration](provider-integration.md#connector-gcp-pi).
   - **GCP credentials file**: If you select **Google Cloud service account**, upload your Google Cloud credentials JSON
     file. For information about how to set these up, see [Create credentials](https://developers.google.com/workspace/guides/create-credentials#create_credentials_for_a_service_account).

   **GCP Pub/Sub details**
   - **Pub/Sub Project ID**: ID for the Google Cloud project where the Pub/Sub is located.
   - **Pub/Sub Topic ID**: The Pub/Sub topic containing messages that have to be polled.
   - **Pub/Sub Subscription ID**: The subscription ID for the Pub/Sub topic.
2. Click **Continue**.

### Configuration

**Connection details**

- **Maximum number of messages to be polled in a request**: Maximum number of messages to be polled in a single Pub/Sub pull request.
- **Maximum time in seconds to retry on errors**: The maximum time
  in seconds that the Pub/Sub client tries polling records from
  the Pub/Sub topic.
- **Pub/Sub Message Data format**: Sets the initial format for
  message data the connector gets from Google Cloud Pub/Sub. The option
  `utf_8` converts message data (bytes) into UTF-8 based string
  format. The `bytes` option keeps the incoming data unchanged.
  Defaults to `utf_8`.
- **Output Data format**: Sets the output data format for values.
  Valid entries are AVRO, JSON and PROTOBUF. Defaults to `JSON`. Set this to
  `AVRO` when **Pub/Sub Message Data Format** is set to `bytes`.

### **Show advanced configurations**

**Additional Configs**

- **Value Converter Decimal Format**: Specifies the `JSON` or `JSON_SR` serialization format for Connect `DECIMAL` logical type values with two allowed literals:
  `BASE64` to serialize `DECIMAL` logical types as base64 encoded binary data, and
  `NUMERIC` to serialize `DECIMAL` logical type values in `JSON` or `JSON_SR` as a number representing the decimal value.
- **Value Converter Replace Null With Default**: Specifies whether to replace fields that have a default value and that are null to the default value. When set to `true`, the connector uses the default value; otherwise, it uses `null`. Applies to the `JSON` converter.
- **Key Converter Schema ID Serializer**: The class name of the schema ID serializer for keys. This is used to serialize schema IDs in the message headers.
- **Value Converter Reference Subject Name Strategy**: Sets the subject reference name strategy for values. Valid entries are `DefaultReferenceSubjectNameStrategy` or `QualifiedReferenceSubjectNameStrategy`. You can use this strategy only with `PROTOBUF` format; the default strategy is `DefaultReferenceSubjectNameStrategy`.
- **Value Converter Schemas Enable**: Includes schema within each of the serialized values. Input messages must contain `schema` and `payload` fields and must not contain additional fields. For plain `JSON` data, set this to `false`. Applies to the `JSON` converter.
- **Errors Tolerance**: Use this property to configure the connector’s error handling behavior.

  #### WARNING
  Use this property with caution for sink connectors, as it can lead to data loss. If you set this property to `all`, the connector does not fail on errant records, but logs them (and sends to DLQ for sink connectors) and continues processing. If you set this property to `none`, the connector task fails on errant records.
- **Value Converter Connect Meta Data**: Enables the Connect converter to add its metadata to the output schema. Applies to Avro converters.
- **Value Converter Value Subject Name Strategy**: Determines how to construct the subject name under which the value schema is registered with Schema Registry.
- **Key Converter Key Subject Name Strategy**: Determines how to construct the subject name for key schema registration.
- **Value Converter Ignore Default For Nullables**: When set to `true`, this property ensures that the corresponding record in Kafka is `null`, instead of showing the default column value. Applies to the `AVRO`, `PROTOBUF`, and `JSON_SR` converters.
- **Value Converter Schema ID Serializer**: The class name of the schema ID serializer for values. This is used to serialize schema IDs in the message headers.

**Auto-restart policy**

- **Enable Connector Auto-restart**: Enables the auto-restart behavior of the connector and its
  task in the event of user-actionable errors. Defaults to `true`, enabling the connector to
  automatically restart in case of user-actionable errors. Set this property to `false` to
  disable auto-restart for failed connectors. If disabled, you must manually restart the connector.

**Transforms**

- **Single Message Transformations**: To add a new SMT, see [Add transforms](single-message-transforms.md#cc-single-message-transforms-ui).
  For more information about unsupported SMTs, see
  [Unsupported transformations](single-message-transforms.md#cc-single-message-transforms-unsupported-transforms).

**Processing position**

- **Set offsets**: Click **Set offsets** to define a specific offset for
  this connector to begin procession data from. For more information
  on managing offsets, see [Manage offsets](offsets.md#connect-custom-offsets).

- Click **Continue**

### Sizing

Based on the number of topic partitions you select, you will be provided
with a recommended number of tasks.

1. To change the number of tasks, use the Range Slider to select the
   desired number of tasks.
2. Click **Continue**.

### Review and Launch

1. Verify the connection details by previewing the running configuration.
2. Once you’ve validated that the properties are configured to your
   satisfaction, click **Launch**.
   ![Launch the connector](images/ccloud-googlepubsub-source-launch-connector.png)

   The status for the connector should go from **Provisioning** to
   **Running**.
   ![Check the connector status](images/ccloud-googlepubsub-source-status.png)

#### Step 5: Check the Kafka topic

After the connector is running, verify that messages are populating your Kafka
topic.

For more information and examples to use with the Confluent Cloud API for Connect,
see the [Confluent Cloud API for Connect Usage Examples](connect-api-section.md#ccloud-connect-api) 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](#cc-google-pubsub-source-prereqs) completed.

#### Step 1: List the available connectors

Enter the following command to list available connectors:

```none
confluent connect plugin list
```

#### Step 2: List the connector configuration properties

Enter the following command to show the connector configuration properties:

```none
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 example shows the required connector properties.

```text
{
    "name" : "confluent-pubsub-source",
    "connector.class": "PubSubSource",
    "kafka.auth.mode": "KAFKA_API_KEY",
    "kafka.api.key": "<my-kafka-api-key>",
    "kafka.api.secret" : "<my-kafka-api-secret>",
    "kafka.topic" : "customers",
    "gcp.pubsub.credentials.json" : "omitted",
    "gcp.pubsub.project.id": "<gcp-project-ID>",
    "gcp.pubsub.topic.id":"<pubsub-topic-ID>",
    "gcp.pubsub.subscription.id": "<pubsub-subscription-ID>",
    "tasks.max" : "1"
}
```

Note the following property definitions:

* `"name"`: Sets a name for your new connector.
* `"connector.class"`: Identifies the connector plugin name.

* `"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](service-account.md#s3-cloud-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:
  ```bash
  confluent iam service-account list
  ```

  For example:
  ```bash
  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
  ```

* `"gcp.pubsub.credentials.json"`: This contains the contents of the
  downloaded JSON file. See [Formatting credentials](#cc-pubsub-json-config-format) for details about
  how to format and use the contents of the downloaded credentials file.

**SMTs**: For details about adding SMTs using the Confluent CLI, see the [Single Message Transformations](single-message-transforms.md#cc-single-message-transforms) documentation.

See [Configuration Properties](#cc-gcs-pubsub-source-config-properties) for all property values and
definitions.

<a id="cc-pubsub-json-config-format"></a>

##### Formatting credentials

The contents of the downloaded credentials file must be converted to string
format before it can be used in the connector configuration.

1. Convert the JSON file contents into string format. You can use an online
   converter tool to do this. For example: [JSON to String Online Converter](https://tools.knowledgewalls.com/jsontostring).
2. Add an escape character (`\`) before all `\n` entries in the Private Key
   section so that each section begins with `\\n` (see the highlighted lines
   below). The example below has been formatted so that the `\\n` entries are
   easier to see. Most of the credentials key has been omitted.
   ```json
     {
         "name" : "confluent-pubsub-source",
         "connector.class" : "PubSubSource",
         "kafka.api.key" : "<my-kafka-api-key>",
         "kafka.api.secret" : "<my-kafka-api-secret>",
         "gcp.pubsub.credentials.json" : "{\"type\":\"service_account\",\"project_id\":\"connect-
         1234567\",\"private_key_id\":\"omitted\",
         \"private_key\":\"-----BEGIN PRIVATE KEY-----
         \\nMIIEvAIBADANBgkqhkiG9w0BA
         \\n6MhBA9TIXB4dPiYYNOYwbfy0Lki8zGn7T6wovGS5pzsIh
         \\nOAQ8oRolFp\rdwc2cC5wyZ2+E+bhwn
         \\nPdCTW+oZoodY\\nOGB18cCKn5mJRzpiYsb5eGv2fN\/J
         \\n...rest of key omitted...
         \\n-----END PRIVATE KEY-----\\n\",
         \"client_email\":\"pub-sub@connect-123456789.iam.gserviceaccount.com\",
         \"client_id\":\"123456789\",\"auth_uri\":\"https:\/\/accounts.google.com\/o\/oauth2\/
         auth\",\"token_uri\":\"https:\/\/oauth2.googleapis.com\/
         token\",\"auth_provider_x509_cert_url\":\"https:\/\/
         www.googleapis.com\/oauth2\/v1\/
         certs\",\"client_x509_cert_url\":\"https:\/\/www.googleapis.com\/
         robot\/v1\/metadata\/x509\/pub-sub%40connect-
         123456789.iam.gserviceaccount.com\"}",
         "gcp.pubsub.project.id": "<gcp-project-ID>",
         "gcp.pubsub.topic.id":"<pubsub-topic-ID>",
         "gcp.pubsub.subscription.id": "<pubsub-subscription-ID>",
         "tasks.max" : "1"
     }
   ```
3. Add all the converted string content to the `"keyfile"` credentials section of your configuration file as shown in the example above.

#### Step 4: Load the configuration file and create the connector

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

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

For example:

```bash
confluent connect cluster create --config-file pubsub-source-config.json
```

Example output:

```text
Created connector confluent-pubsub-source lcc-ix4dl
```

#### Step 5: Check the connector status

Enter the following command to check the connector status:

```bash
confluent connect cluster list
```

Example output:

```text
ID          |       Name              | Status  | Type
+-----------+-------------------------+---------+-------+
lcc-ix4dl   | confluent-pubsub-source | RUNNING | source
```

#### Step 6: Check the Kafka topic.

After the connector is running, verify that messages are populating your Kafka topic.

For more information and examples to use with the Confluent Cloud API for Connect,
see the [Confluent Cloud API for Connect Usage Examples](connect-api-section.md#ccloud-connect-api) section.

<a id="cc-gcs-pubsub-source-config-properties"></a>

## 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](/platform/current/connect/kafka_connectors.html).

### How should we connect to your data?

`name`
: Sets a name for your connector.
  <br/>
  * 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, whenever possible.
  <br/>
  * Type: string
  * Valid Values: SERVICE_ACCOUNT, KAFKA_API_KEY
  * Importance: high

`kafka.api.key`
: Kafka API Key. Required when kafka.auth.mode==KAFKA_API_KEY.
  <br/>
  * 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.
  <br/>
  * Type: string
  * Importance: high

`kafka.api.secret`
: Secret associated with Kafka API key. Required when kafka.auth.mode==KAFKA_API_KEY.
  <br/>
  * Type: password
  * Importance: high

### Which topic do you want to send data to?

`kafka.topic`
: Identifies the topic name to write the data to.
  <br/>
  * Type: list
  * Importance: high

### GCP credentials

`provider.integration.id`
: Select an existing integration that has access to your resource. In case you need to integrate a new Google Service Account, use provider integration
  <br/>
  * Type: string
  * Importance: high

`authentication.method`
: Select how you want to authenticate with GCP.
  <br/>
  * Type: string
  * Default: Google cloud service account
  * Valid Values: Google cloud service account, Google service account impersonation
  * Importance: high

`gcp.pubsub.credentials.json`
: GCP service account JSON file with read permissions for Pub/Sub.
  <br/>
  * Type: password
  * Importance: high

### GCP Pub/Sub details

`gcp.pubsub.project.id`
: ID for the GCP project where the Pub/Sub is located.
  <br/>
  * Type: string
  * Importance: high

`gcp.pubsub.topic.id`
: The Pub/Sub topic containing messages that have to be polled.
  <br/>
  * Type: string
  * Importance: high

`gcp.pubsub.subscription.id`
: The subscription ID for the Pub/Sub topic.
  <br/>
  * Type: string
  * Importance: high

### Connection details

`gcp.pubsub.message.max.count`
: The maximum number of messages to be polled in a single Pub/Sub pull request.
  <br/>
  * Type: int
  * Default: 10000
  * Valid Values: [1000,…]
  * Importance: low

`gcp.pubsub.max.retry.time`
: The maximum time in seconds that the Pub/Sub client will try polling records from Pub/Sub topic.
  <br/>
  * Type: int
  * Default: 5
  * Valid Values: [5,…]
  * Importance: low

`gcp.pubsub.data.format`
: Pub/Sub Message Data format. This property defines the initial format of message data obtained from the GCP Pub/Sub.
  <br/>
  > utf_8 will convert pub/sub message data (bytes) into utf-8 based string format.
  <br/>
  > bytes will keep the pub/sub message data (bytes) without any conversion.
  * Type: string
  * Default: utf_8
  * Valid Values: bytes, utf_8
  * Importance: low

`output.data.format`
: Set the output data format for values. Valid entries are AVRO, PROTOBUF and JSON. Recommended to use AVRO or PROTOBUF format when setting gcp.pubsub.data.format as BYTES
  <br/>
  * Type: string
  * Default: JSON
  * Valid Values: AVRO, JSON, PROTOBUF
  * Importance: low

### Number of tasks for this connector

`tasks.max`
: Maximum number of tasks for the connector.
  <br/>
  * Type: int
  * Valid Values: [1,…]
  * Importance: high

### Additional Configs

`header.converter`
: The converter class for the headers. This is used to serialize and deserialize the headers of the messages.
  <br/>
  * Type: string
  * Importance: low

`producer.override.compression.type`
: The compression type for all data generated by the producer. Valid values are none, gzip, snappy, lz4, and zstd.
  <br/>
  * Type: string
  * Importance: low

`producer.override.linger.ms`
: The producer groups together any records that arrive in between request transmissions into a single batched request. More details can be found in the documentation: [https://docs.confluent.io/platform/current/installation/configuration/producer-configs.html#linger-ms](https://docs.confluent.io/platform/current/installation/configuration/producer-configs.html#linger-ms).
  <br/>
  * Type: long
  * Valid Values: [100,…,1000]
  * Importance: low

`value.converter.allow.optional.map.keys`
: Allow optional string map key when converting from Connect Schema to Avro Schema. Applicable for Avro Converters.
  <br/>
  * Type: boolean
  * Importance: low

`value.converter.auto.register.schemas`
: Specify if the Serializer should attempt to register the Schema.
  <br/>
  * Type: boolean
  * Importance: low

`value.converter.connect.meta.data`
: Allow the Connect converter to add its metadata to the output schema. Applicable for Avro Converters.
  <br/>
  * Type: boolean
  * Importance: low

`value.converter.enhanced.avro.schema.support`
: Enable enhanced schema support to preserve package information and Enums. Applicable for Avro Converters.
  <br/>
  * Type: boolean
  * Importance: low

`value.converter.enhanced.protobuf.schema.support`
: Enable enhanced schema support to preserve package information. Applicable for Protobuf Converters.
  <br/>
  * Type: boolean
  * Importance: low

`value.converter.flatten.unions`
: Whether to flatten unions (oneofs). Applicable for Protobuf Converters.
  <br/>
  * Type: boolean
  * Importance: low

`value.converter.generate.index.for.unions`
: Whether to generate an index suffix for unions. Applicable for Protobuf Converters.
  <br/>
  * Type: boolean
  * Importance: low

`value.converter.generate.struct.for.nulls`
: Whether to generate a struct variable for null values. Applicable for Protobuf Converters.
  <br/>
  * Type: boolean
  * Importance: low

`value.converter.int.for.enums`
: Whether to represent enums as integers. Applicable for Protobuf Converters.
  <br/>
  * Type: boolean
  * Importance: low

`value.converter.latest.compatibility.strict`
: Verify latest subject version is backward compatible when use.latest.version is true.
  <br/>
  * Type: boolean
  * Importance: low

`value.converter.object.additional.properties`
: Whether to allow additional properties for object schemas. Applicable for JSON_SR Converters.
  <br/>
  * Type: boolean
  * Importance: low

`value.converter.optional.for.nullables`
: Whether nullable fields should be specified with an optional label. Applicable for Protobuf Converters.
  <br/>
  * Type: boolean
  * Importance: low

`value.converter.optional.for.proto2`
: Whether proto2 optionals are supported. Applicable for Protobuf Converters.
  <br/>
  * Type: boolean
  * Importance: low

`value.converter.scrub.invalid.names`
: Whether to scrub invalid names by replacing invalid characters with valid characters. Applicable for Avro and Protobuf Converters.
  <br/>
  * Type: boolean
  * Importance: low

`value.converter.use.latest.version`
: Use latest version of schema in subject for serialization when auto.register.schemas is false.
  <br/>
  * Type: boolean
  * Importance: low

`value.converter.use.optional.for.nonrequired`
: Whether to set non-required properties to be optional. Applicable for JSON_SR Converters.
  <br/>
  * Type: boolean
  * Importance: low

`value.converter.wrapper.for.nullables`
: Whether nullable fields should use primitive wrapper messages. Applicable for Protobuf Converters.
  <br/>
  * Type: boolean
  * Importance: low

`value.converter.wrapper.for.raw.primitives`
: Whether a wrapper message should be interpreted as a raw primitive at root level. Applicable for Protobuf Converters.
  <br/>
  * Type: boolean
  * Importance: low

`errors.tolerance`
: Use this property if you would like to configure the connector’s error handling behavior. WARNING: This property should be used with CAUTION for SOURCE CONNECTORS as it may lead to dataloss. If you set this property to ‘all’, the connector will not fail on errant records, but will instead log them (and send to DLQ for Sink Connectors) and continue processing. If you set this property to ‘none’, the connector task will fail on errant records.
  <br/>
  * Type: string
  * Default: none
  * Importance: low

`key.converter.key.schema.id.serializer`
: The class name of the schema ID serializer for keys. This is used to serialize schema IDs in the message headers.
  <br/>
  * Type: string
  * Default: io.confluent.kafka.serializers.schema.id.PrefixSchemaIdSerializer
  * Importance: low

`key.converter.key.subject.name.strategy`
: How to construct the subject name for key schema registration.
  <br/>
  * Type: string
  * Default: TopicNameStrategy
  * Importance: low

`value.converter.decimal.format`
: Specify the JSON/JSON_SR serialization format for Connect DECIMAL logical type values with two allowed literals:
  <br/>
  BASE64 to serialize DECIMAL logical types as base64 encoded binary data and
  <br/>
  NUMERIC to serialize Connect DECIMAL logical type values in JSON/JSON_SR as a number representing the decimal value.
  <br/>
  * Type: string
  * Default: BASE64
  * Importance: low

`value.converter.flatten.singleton.unions`
: Whether to flatten singleton unions. Applicable for Avro and JSON_SR Converters.
  <br/>
  * Type: boolean
  * Default: false
  * Importance: low

`value.converter.ignore.default.for.nullables`
: When set to true, this property ensures that the corresponding record in Kafka is NULL, instead of showing the default column value. Applicable for AVRO,PROTOBUF and JSON_SR Converters.
  <br/>
  * Type: boolean
  * Default: false
  * Importance: low

`value.converter.reference.subject.name.strategy`
: Set the subject reference name strategy for value. Valid entries are DefaultReferenceSubjectNameStrategy or QualifiedReferenceSubjectNameStrategy. Note that the subject reference name strategy can be selected only for PROTOBUF format with the default strategy being DefaultReferenceSubjectNameStrategy.
  <br/>
  * Type: string
  * Default: DefaultReferenceSubjectNameStrategy
  * Importance: low

`value.converter.replace.null.with.default`
: Whether to replace fields that have a default value and that are null to the default value. When set to true, the default value is used, otherwise null is used. Applicable for JSON Converter.
  <br/>
  * Type: boolean
  * Default: true
  * Importance: low

`value.converter.schemas.enable`
: Include schemas within each of the serialized values. Input messages must contain schema and payload fields and may not contain additional fields. For plain JSON data, set this to false. Applicable for JSON Converter.
  <br/>
  * Type: boolean
  * Default: false
  * Importance: low

`value.converter.value.schema.id.serializer`
: The class name of the schema ID serializer for values. This is used to serialize schema IDs in the message headers.
  <br/>
  * Type: string
  * Default: io.confluent.kafka.serializers.schema.id.PrefixSchemaIdSerializer
  * Importance: low

`value.converter.value.subject.name.strategy`
: Determines how to construct the subject name under which the value schema is registered with Schema Registry.
  <br/>
  * Type: string
  * Default: TopicNameStrategy
  * Importance: low

### Auto-restart policy

`auto.restart.on.user.error`
: Enable connector to automatically restart on user-actionable errors.
  <br/>
  * Type: boolean
  * Default: true
  * Importance: medium

<a id="cc-google-pubsub-source-faqs"></a>

## Frequently asked questions

Find answers to frequently asked questions about Google Cloud Pub/Sub Source connector in Confluent Cloud.

### Why is the connector failing with authentication errors?

Authentication failures typically occur due to one of the following reasons:

- **Incorrect or expired credentials**: Verify that the Google Cloud service account credentials JSON file is correctly formatted and has not expired.
- **Insufficient IAM permissions**: The Google Cloud service account must have the required roles. Ensure the service account is granted `roles/pubsub.subscriber` and `roles/pubsub.viewer` permissions in Google Cloud.
  See the [List of Pub/Sub IAM Roles](https://cloud.google.com/pubsub/docs/access-control#roles) for more information.
- **Incorrect authentication method**: When using Confluent Provider Integration for Google Cloud, verify that the provider integration is correctly configured and that the connector is set to use the provider integration authentication method instead of JSON credentials.

### What are the most common configuration errors for this connector?

The most common configuration errors include:

- **Incorrect project ID**: Ensure `gcp.pubsub.project.id` matches your Google Cloud project ID exactly.
- **Invalid subscription ID**: Ensure `gcp.pubsub.subscription.id` references an existing Pub/Sub subscription in your Google Cloud project.
- **Missing topic ID**: Ensure `gcp.pubsub.topic.id` is specified and exists in your Google Cloud project.
- **Mismatched Kafka topic**: Verify that the `kafka.topic` property references the correct destination topic in your Confluent Cloud cluster.

### Why is the connector not working with AVRO data?

When ingesting AVRO-formatted messages from Pub/Sub, ensure that:

- The AVRO schema is properly registered in Confluent Cloud Schema Registry if you’re using schema validation.
- Your connector configuration specifies the correct value converter. For AVRO data, you may need to configure `value.converter` settings appropriately.
- The Pub/Sub messages contain valid AVRO-encoded data that matches the expected schema.

If you experience issues deserializing AVRO data, verify the schema compatibility and ensure the data format matches what the connector expects.

### How do I configure SMTs?

When using SMTs with the connector:

- Only use SMTs that are supported in Confluent Cloud. See [Configure Single Message Transformations for Kafka Connectors in Confluent Cloud](single-message-transforms.md#cc-single-message-transforms) for the list of supported SMTs.
- Custom SMTs are not supported with this connector. If you require custom transformation logic, consider using a custom connector or implementing transformations
  in a stream processing application.
- Ensure SMT configurations are correctly specified. Common issues include incorrect field names, type mismatches, or unsupported SMT operations.

For limitations, see [SMT Limitations](single-message-transforms.md#cc-single-message-transforms-limitations).

### Why is the connector failing to connect to Google Cloud Pub/Sub?

Connectivity issues are often related to network restrictions:

- **VPC Service Controls**: If your Google Cloud project uses VPC Service Controls, you must configure a service perimeter that allows access from Confluent IP addresses.
  Work with your Google Cloud administrator to add the required ingress/egress rules.
- **Firewall rules**: Ensure that firewall rules in your Google Cloud project allow inbound connections from Confluent Confluent Cloud.
- **Private Service Connect (PSC)**: If you’re using PSC for private connectivity, verify that the PSC endpoint is properly configured and that the connector can access Google Cloud APIs through the private connection.

### Why is the connector failing with `message too big` errors?

Kafka has a maximum message size limit of 8 MB for standard clusters and 20 MB for dedicated clusters in Confluent Cloud. If your Pub/Sub messages exceed this limit:

- Check the size of messages in your Pub/Sub subscription. Messages larger than the Kafka maximum message size will cause the connector to fail.
- Consider splitting large messages into smaller chunks before publishing to Pub/Sub.
- If you control the message source, implement message size controls to ensure messages stay within Kafka limits.

### How do I split JSON arrays into individual messages?

The connector does not natively split JSON arrays into separate Kafka messages. Each Pub/Sub message is written as a single Kafka message.

To split JSON arrays:

- Use a supported SMT if available for your use case. See [Configure Single Message Transformations for Kafka Connectors in Confluent Cloud](single-message-transforms.md#cc-single-message-transforms).
- Alternatively, split the arrays before publishing to Pub/Sub.
- For complex transformations, consider using a stream processing applications like ksqlDB or Confluent Cloud for Apache Flink to process and transform the data after it arrives in Kafka.

### What happens to messages if the connector stops or fails?

Messages in the Pub/Sub subscription are retained according to the subscription’s message retention policy. When the connector restarts:

- Messages that were not acknowledged will be redelivered.
- The connector will resume consumption from the last committed offset.
- No messages are lost unless they expire based on the subscription’s retention settings.

## Next Steps

For an example that shows fully managed Confluent Cloud connectors in action with
Confluent Cloud for Apache Flink, see the [Cloud ETL Demo](/platform/current/tutorials/examples/cloud-etl/docs/index.html).
This example also shows how to use Confluent CLI to manage your resources in
Confluent Cloud.

[![image](images/topology.png)](https://docs.confluent.io/platform/current/tutorials/examples/cloud-etl/docs/index.html)
