This is an automated email from the ASF dual-hosted git repository.

snuyanzin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/flink-connector-gcp-pubsub.git


The following commit(s) were added to refs/heads/main by this push:
     new a8ccb5b  [FLINK-35779][Connectors/Google PubSub] Update documentation 
for PubSubSinkV2 (#29)
a8ccb5b is described below

commit a8ccb5b41c9a144fb4a58f8092c0cf33b618583c
Author: Ahmed Hamdy <[email protected]>
AuthorDate: Mon Jul 29 07:55:33 2024 +0100

    [FLINK-35779][Connectors/Google PubSub] Update documentation for 
PubSubSinkV2 (#29)
---
 docs/content/docs/connectors/datastream/pubsub.md | 45 +++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/docs/content/docs/connectors/datastream/pubsub.md 
b/docs/content/docs/connectors/datastream/pubsub.md
index a39dbb3..b509cc5 100644
--- a/docs/content/docs/connectors/datastream/pubsub.md
+++ b/docs/content/docs/connectors/datastream/pubsub.md
@@ -96,6 +96,51 @@ SinkFunction<SomeObject> pubsubSink = PubSubSink.newBuilder()
 dataStream.addSink(pubsubSink);
 ```
 
+Note: This Sink has been deprecated in favor of the `PubSubSinkV2` which 
extends the new `SinkV2` API.
+
+
+### PubSubSinkV2
+
+Alternatively to the `PubSubSink` you can use the `PubSubSinkV2` which extends 
the new `SinkV2` API.
+You can instantiate the `PubSubSinkV2` using the builder `PubSubSinkV2Builder` 
as follows:
+
+```java
+PubSubSinkV2Builder<String> pubSubSink =  
PubSubSinkV2Builder.<String>builder()         
+        .setProjectId("project-id")
+        .setTopicId("topic-id")
+        .setGcpPublisherConfig(gcpPublisherConfig)
+        .setSerializationSchema(new SimpleStringSchema())
+        .setMaximumInflightMessages(10)
+        .setFailOnError(true)
+        .build();
+```
+The `PubSubSinkV2` uses `com.google.cloud.pubsub.v1.Publisher` to publish 
messages to PubSub. 
+
+The Sink is configured using `GcpPublisherConfig` which can be created using 
the builder `GcpPublisherConfigBuilder` as follows:
+
+```java
+GcpPublisherConfig gcpPublisherConfig = GcpPublisherConfigBuilder.builder()
+        .setCredentialsProvider(credentialsProvider)
+        .setBatchingSettings(BatchingSettings.newBuilder()
+                .setDelayThreshold(Duration.ofMillis(10))
+                .setElementCountThreshold(10L)
+                .build())
+        .setRetrySettings(RetrySettings.newBuilder()
+                .setInitialRpcTimeout(Duration.ofSeconds(10))
+                .setMaxRpcTimeout(Duration.ofSeconds(10))
+                .setTotalTimeout(Duration.ofSeconds(10))
+                .setInitialRetryDelay(Duration.ofSeconds(10))
+                .setMaxRetryDelay(Duration.ofSeconds(10))
+                .setRetryDelayMultiplier(1.0)
+                .setRpcTimeoutMultiplier(1.0)
+                .setMaxAttempts(10)
+                .build())
+        .setEnableCompression(true)
+        .build();
+```
+
+The `PubSubSinkV2` does not buffer messages before sending them to PubSub. 
Instead, it uses the `Publisher`'s batching settings to batch messages before 
sending them to PubSub.
+
 ### Google Credentials
 
 Google uses 
[Credentials](https://cloud.google.com/docs/authentication/production) to 
authenticate and authorize applications so that they can use Google Cloud 
Platform resources (such as PubSub).

Reply via email to