The Google Pub/Sub component enables integration with the Google Cloud Pub/Sub service to publish and consume messages. It is ideal for asynchronous communication between applications, facilitating data exchange in distributed scenarios.
URI Syntax: google-pubsub:projectId:destinationName
Path parameters
Name | Description | Default | Type |
|---|---|---|---|
projectId (common) | (required) The Google Cloud Pub/Sub project ID. | — | String |
destinationName (common) | (required) The destination name. For the consumer (trigger), this will be the subscription name, while for the producer (connector), this will be the topic name. | — | String |
Query parameters
Name | Description | Default | Type |
|---|---|---|---|
serviceAccountKey (common) | The service account key that can be used as credentials for the Pub/Sub publisher/subscriber. It can be loaded by default from the classpath, but you can add the classpath:, file:, or http: prefix to load the resource from different systems. | — | String |
IMPORTANTBefore running the integration flow, import the Google Cloud service account key into a config map. This key will be used as a resource in the integration:
The "key.json" file contains the service account credentials in JSON format. In Integrations, this key will be configured as a Resource file.
Read more about Resources files.
The integration subscribes to a topic (topic-01) through a subscription called camel-k and consumes messages published by another integration:
The flow starts with the connection to Google Cloud Pub/Sub through the google-pubsub component. In the URI, the project ID (registry-ipaas-testing) and the subscription name (camel-k) that will be monitored to receive messages are specified.
In the parameters, the serviceAccountKey is configured to point to the key.json file, containing the service account credentials needed to authenticate the connection to Google Cloud.
The flow processes received messages through the log component, which records both the message content (${body}) and its headers (${headers}), allowing visualization of data received from the subscription.
IMPORTANTA Pull-type subscription must be created in the Pub/Sub console for use in the code.

We use cookies to enhance your experience on our site. By continuing to browse, you agree to our use of cookies.Learn more