Google Pub/Sub Sink Connector
Type |
Sink |
Class |
|
Target System |
Google Cloud Pub/Sub |
Maintainer |
|
License |
Apache License 2.0 |
Project |
|
Download |
|
This page documents version 2.8.2. Newer versions should be compatible unless there are breaking changes, but field names or default values may differ. If you notice discrepancies, please contact Axual Support. |
The GoogleCloudPlatform/pubsub repository used by this connector has been deprecated by Google since 2022.
The successor project is googleapis/java-pubsub-group-kafka-connector.
Migration involves updating the connector class names and download location.
This documentation page has not yet been updated to reflect the new project.
|
Description
The Google Pub/Sub Sink Connector consumes records from a Kafka topic and publishes them as messages to a Google Cloud Pub/Sub topic.
It is maintained by Google as part of the open-source github.com/GoogleCloudPlatform/pubsub.
Features
-
Consume Kafka records and publish to a Google Cloud Pub/Sub topic
-
Supports GCP service account authentication via JSON key file
When to Use
-
You need to bridge Kafka into Google Cloud Pub/Sub for downstream GCP services.
-
You want to forward Kafka topic data into Pub/Sub for fan-out delivery.
When NOT to Use
-
You need to read from Pub/Sub into Kafka — use the Google Pub/Sub Source Connector instead.
Installation
The connector is available from the GitHub Releases.
-
Navigate to the releases page and select the version matching your Kafka Connect installation.
-
Download the JAR file.
For installation steps, see Installing Connector Plugins.
Configuration
For the complete configuration reference, see the official sink connector documentation.
| To configure a connector in Axual Self-Service, see Starting Connectors. TIP: For Infrastructure-as-Code deployment, see the Axual Kafka Connect Boilerplates for Terraform and Management API boilerplates. |
Getting Started
Prerequisites
Google Cloud project, service account, and Pub/Sub topic
Ensure you have completed the setup described in the Pub/Sub Source Connector prerequisites, including creating a GCP service account and a target Pub/Sub topic.
You may optionally create a second Pub/Sub topic (e.g. my_pubsub_google_target) for the sink to write to.
Steps
Step 1 — Create a connector application
-
Follow the Configure and install a connector documentation to set up a new Connector-Application.
Let’s call itmy_pubsub_sink.
The plugin name iscom.google.pubsub.kafka.sink.CloudPubSubSinkConnector.
If a plugin isn’t available, ask a platform operator to install plugins.
Step 2 — Configure the connector
-
Open the previously downloaded GCP service account key file. Provide the following configuration:
cps.projectCopy the
project_idvalue from the downloaded key fileExample value:
decisive-lambda-369420gcp.credentials.jsonCopy the entire JSON as-is from the downloaded key file. Newlines will be automatically excluded.
cps.topicmy_pubsub_google_targettopicsFor advanced options, see the official sink connector documentation.
-
Authorize the
my_pubsub_sinksink Connector-Application to consume the{stream-name}stream.
Step 4 — Verify
Verify that records have arrived in the target Pub/Sub topic:
-
Open the topics page.
-
Click the
my_pubsub_google_targettopic. -
Click the MESSAGES tab.
-
Select the available subscription from the dropdown.
-
Click PULL.
-
The values will be displayed as base64-encoded strings.
Cleanup
When you are done:
-
Stop the connector application in Axual Self-Service.
-
Remove stream access for the application if no longer needed.
-
Return to your Pub/Sub topics list and delete your Google topics.
-
Delete the
my-pubsub-adminservice account. -
Check your IAM principals and remove any principals created as part of this example.
Examples
Minimal configuration
{
"name": "my-pubsub-sink",
"config": {
"connector.class": "com.google.pubsub.kafka.sink.CloudPubSubSinkConnector",
"cps.project": "decisive-lambda-369420",
"gcp.credentials.json": "<contents-of-gcp-service-account-key-json>",
"cps.topic": "my_pubsub_google_target",
"topics": "my_pubsub_kafka_topic"
}
}
License
Google Pub/Sub source and sink connectors are licensed under the Apache License, Version 2.0.