diff --git a/.github/workflows/hermetic_library_generation.yaml b/.github/workflows/hermetic_library_generation.yaml
index f0b1369c8..336ac2c8c 100644
--- a/.github/workflows/hermetic_library_generation.yaml
+++ b/.github/workflows/hermetic_library_generation.yaml
@@ -37,7 +37,7 @@ jobs:
with:
fetch-depth: 0
token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }}
- - uses: googleapis/sdk-platform-java/.github/scripts@v2.57.0
+ - uses: googleapis/sdk-platform-java/.github/scripts@v2.58.0
if: env.SHOULD_RUN == 'true'
with:
base_ref: ${{ github.base_ref }}
diff --git a/.github/workflows/unmanaged_dependency_check.yaml b/.github/workflows/unmanaged_dependency_check.yaml
index 006d4eecb..704e61807 100644
--- a/.github/workflows/unmanaged_dependency_check.yaml
+++ b/.github/workflows/unmanaged_dependency_check.yaml
@@ -17,6 +17,6 @@ jobs:
# repository
.kokoro/build.sh
- name: Unmanaged dependency check
- uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v3.47.0
+ uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v3.48.0
with:
bom-path: google-cloud-pubsub-bom/pom.xml
diff --git a/.kokoro/presubmit/graalvm-native-a.cfg b/.kokoro/presubmit/graalvm-native-a.cfg
index eab7259dc..d72ed3f0e 100644
--- a/.kokoro/presubmit/graalvm-native-a.cfg
+++ b/.kokoro/presubmit/graalvm-native-a.cfg
@@ -3,7 +3,7 @@
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
- value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.46.3" # {x-version-update:google-cloud-shared-dependencies:current}
+ value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.48.0" # {x-version-update:google-cloud-shared-dependencies:current}
}
env_vars: {
diff --git a/.kokoro/presubmit/graalvm-native-b.cfg b/.kokoro/presubmit/graalvm-native-b.cfg
index 90b98e715..f2e296b84 100644
--- a/.kokoro/presubmit/graalvm-native-b.cfg
+++ b/.kokoro/presubmit/graalvm-native-b.cfg
@@ -3,7 +3,7 @@
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
- value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.46.3" # {x-version-update:google-cloud-shared-dependencies:current}
+ value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.48.0" # {x-version-update:google-cloud-shared-dependencies:current}
}
env_vars: {
diff --git a/.kokoro/presubmit/graalvm-native-c.cfg b/.kokoro/presubmit/graalvm-native-c.cfg
index b2291db97..68512fbff 100644
--- a/.kokoro/presubmit/graalvm-native-c.cfg
+++ b/.kokoro/presubmit/graalvm-native-c.cfg
@@ -3,7 +3,7 @@
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
- value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_c:3.46.3" # {x-version-update:google-cloud-shared-dependencies:current}
+ value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_c:3.48.0" # {x-version-update:google-cloud-shared-dependencies:current}
}
env_vars: {
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 39b977b05..6657c1065 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,29 @@
# Changelog
+## [1.139.4](https://github.com/googleapis/java-pubsub/compare/v1.139.3...v1.139.4) (2025-05-15)
+
+
+### Bug Fixes
+
+* **deps:** Update the Java code generator (gapic-generator-java) to 2.57.0 ([017eb0f](https://github.com/googleapis/java-pubsub/commit/017eb0f78423fde3edd42a07677df49512085633))
+* **deps:** Update the Java code generator (gapic-generator-java) to 2.58.0 ([3713edb](https://github.com/googleapis/java-pubsub/commit/3713edb9420f792b7c7ad4e430ca05b5942656ff))
+
+
+### Dependencies
+
+* Update dependency com.google.cloud:google-cloud-bigquery to v2.50.0 ([#2422](https://github.com/googleapis/java-pubsub/issues/2422)) ([993b2d0](https://github.com/googleapis/java-pubsub/commit/993b2d06ce6b45bb72faa9d6959cddc14a9cf60e))
+* Update dependency com.google.cloud:google-cloud-core to v2.55.0 ([#2413](https://github.com/googleapis/java-pubsub/issues/2413)) ([3e181e7](https://github.com/googleapis/java-pubsub/commit/3e181e7c4469eadcf6f148ee0a30aae1cfa825f3))
+* Update dependency com.google.cloud:google-cloud-core to v2.56.0 ([#2427](https://github.com/googleapis/java-pubsub/issues/2427)) ([b2a3e35](https://github.com/googleapis/java-pubsub/commit/b2a3e35ced2d1715c37207f98740889635326dc1))
+* Update dependency com.google.cloud:google-cloud-storage to v2.52.2 ([#2421](https://github.com/googleapis/java-pubsub/issues/2421)) ([1224ee5](https://github.com/googleapis/java-pubsub/commit/1224ee51da27e447560076b0d51ba90515566bd9))
+* Update dependency com.google.cloud:sdk-platform-java-config to v3.47.0 ([#2418](https://github.com/googleapis/java-pubsub/issues/2418)) ([5f87661](https://github.com/googleapis/java-pubsub/commit/5f876612eb4a54faec3af2c9043aec0adf51e2ec))
+* Update dependency com.google.cloud:sdk-platform-java-config to v3.48.0 ([#2428](https://github.com/googleapis/java-pubsub/issues/2428)) ([cfa91fa](https://github.com/googleapis/java-pubsub/commit/cfa91fa0e85f3f1e517627da3e5befcd46f0803a))
+* Update dependency com.google.cloud.opentelemetry:exporter-trace to v0.34.0 ([#2376](https://github.com/googleapis/java-pubsub/issues/2376)) ([06768cd](https://github.com/googleapis/java-pubsub/commit/06768cd1ac86ae7ae7b91b020cc174b4423e1b9a))
+
+
+### Documentation
+
+* **sample:** Add samples for topic and subscription SMTs ([#2388](https://github.com/googleapis/java-pubsub/issues/2388)) ([f35de28](https://github.com/googleapis/java-pubsub/commit/f35de28396fda595e6ea68c1755a4253d6b097d6))
+
## [1.139.3](https://github.com/googleapis/java-pubsub/compare/v1.139.2...v1.139.3) (2025-05-06)
diff --git a/README.md b/README.md
index 236dd11f4..b266a65ef 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file:
com.google.cloud
libraries-bom
- 26.59.0
+ 26.60.0
pom
import
@@ -43,7 +43,7 @@ If you are using Maven without the BOM, add this to your dependencies:
com.google.cloud
google-cloud-pubsub
- 1.139.1
+ 1.139.3
```
@@ -51,20 +51,20 @@ If you are using Maven without the BOM, add this to your dependencies:
If you are using Gradle 5.x or later, add this to your dependencies:
```Groovy
-implementation platform('com.google.cloud:libraries-bom:26.59.0')
+implementation platform('com.google.cloud:libraries-bom:26.60.0')
implementation 'com.google.cloud:google-cloud-pubsub'
```
If you are using Gradle without BOM, add this to your dependencies:
```Groovy
-implementation 'com.google.cloud:google-cloud-pubsub:1.139.3'
+implementation 'com.google.cloud:google-cloud-pubsub:1.139.4'
```
If you are using SBT, add this to your dependencies:
```Scala
-libraryDependencies += "com.google.cloud" % "google-cloud-pubsub" % "1.139.3"
+libraryDependencies += "com.google.cloud" % "google-cloud-pubsub" % "1.139.4"
```
## Authentication
@@ -252,6 +252,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-pubsub/tree/m
| Create Subscription With Exactly Once Delivery | [source code](https://github.com/googleapis/java-pubsub/blob/main/samples/snippets/src/main/java/pubsub/CreateSubscriptionWithExactlyOnceDelivery.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-pubsub&page=editor&open_in_editor=samples/snippets/src/main/java/pubsub/CreateSubscriptionWithExactlyOnceDelivery.java) |
| Create Subscription With Filtering | [source code](https://github.com/googleapis/java-pubsub/blob/main/samples/snippets/src/main/java/pubsub/CreateSubscriptionWithFiltering.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-pubsub&page=editor&open_in_editor=samples/snippets/src/main/java/pubsub/CreateSubscriptionWithFiltering.java) |
| Create Subscription With Ordering | [source code](https://github.com/googleapis/java-pubsub/blob/main/samples/snippets/src/main/java/pubsub/CreateSubscriptionWithOrdering.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-pubsub&page=editor&open_in_editor=samples/snippets/src/main/java/pubsub/CreateSubscriptionWithOrdering.java) |
+| Create Subscription With Smt Example | [source code](https://github.com/googleapis/java-pubsub/blob/main/samples/snippets/src/main/java/pubsub/CreateSubscriptionWithSmtExample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-pubsub&page=editor&open_in_editor=samples/snippets/src/main/java/pubsub/CreateSubscriptionWithSmtExample.java) |
| Create Topic Example | [source code](https://github.com/googleapis/java-pubsub/blob/main/samples/snippets/src/main/java/pubsub/CreateTopicExample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-pubsub&page=editor&open_in_editor=samples/snippets/src/main/java/pubsub/CreateTopicExample.java) |
| Create Topic With Aws Msk Ingestion Example | [source code](https://github.com/googleapis/java-pubsub/blob/main/samples/snippets/src/main/java/pubsub/CreateTopicWithAwsMskIngestionExample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-pubsub&page=editor&open_in_editor=samples/snippets/src/main/java/pubsub/CreateTopicWithAwsMskIngestionExample.java) |
| Create Topic With Azure Event Hubs Ingestion Example | [source code](https://github.com/googleapis/java-pubsub/blob/main/samples/snippets/src/main/java/pubsub/CreateTopicWithAzureEventHubsIngestionExample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-pubsub&page=editor&open_in_editor=samples/snippets/src/main/java/pubsub/CreateTopicWithAzureEventHubsIngestionExample.java) |
@@ -260,6 +261,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-pubsub/tree/m
| Create Topic With Kinesis Ingestion Example | [source code](https://github.com/googleapis/java-pubsub/blob/main/samples/snippets/src/main/java/pubsub/CreateTopicWithKinesisIngestionExample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-pubsub&page=editor&open_in_editor=samples/snippets/src/main/java/pubsub/CreateTopicWithKinesisIngestionExample.java) |
| Create Topic With Schema Example | [source code](https://github.com/googleapis/java-pubsub/blob/main/samples/snippets/src/main/java/pubsub/CreateTopicWithSchemaExample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-pubsub&page=editor&open_in_editor=samples/snippets/src/main/java/pubsub/CreateTopicWithSchemaExample.java) |
| Create Topic With Schema Revisions Example | [source code](https://github.com/googleapis/java-pubsub/blob/main/samples/snippets/src/main/java/pubsub/CreateTopicWithSchemaRevisionsExample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-pubsub&page=editor&open_in_editor=samples/snippets/src/main/java/pubsub/CreateTopicWithSchemaRevisionsExample.java) |
+| Create Topic With Smt Example | [source code](https://github.com/googleapis/java-pubsub/blob/main/samples/snippets/src/main/java/pubsub/CreateTopicWithSmtExample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-pubsub&page=editor&open_in_editor=samples/snippets/src/main/java/pubsub/CreateTopicWithSmtExample.java) |
| Create Unwrapped Push Subscription Example | [source code](https://github.com/googleapis/java-pubsub/blob/main/samples/snippets/src/main/java/pubsub/CreateUnwrappedPushSubscriptionExample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-pubsub&page=editor&open_in_editor=samples/snippets/src/main/java/pubsub/CreateUnwrappedPushSubscriptionExample.java) |
| Delete Schema Example | [source code](https://github.com/googleapis/java-pubsub/blob/main/samples/snippets/src/main/java/pubsub/DeleteSchemaExample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-pubsub&page=editor&open_in_editor=samples/snippets/src/main/java/pubsub/DeleteSchemaExample.java) |
| Delete Schema Revision Example | [source code](https://github.com/googleapis/java-pubsub/blob/main/samples/snippets/src/main/java/pubsub/DeleteSchemaRevisionExample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-pubsub&page=editor&open_in_editor=samples/snippets/src/main/java/pubsub/DeleteSchemaRevisionExample.java) |
@@ -418,7 +420,7 @@ Java is a registered trademark of Oracle and/or its affiliates.
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-pubsub/java11.html
[stability-image]: https://img.shields.io/badge/stability-stable-green
[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-pubsub.svg
-[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-pubsub/1.139.3
+[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-pubsub/1.139.4
[authentication]: https://github.com/googleapis/google-cloud-java#authentication
[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes
[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles
diff --git a/generation_config.yaml b/generation_config.yaml
index 4ebe3e637..93466f8b5 100644
--- a/generation_config.yaml
+++ b/generation_config.yaml
@@ -1,6 +1,6 @@
-gapic_generator_version: 2.56.3
-googleapis_commitish: 7ab5d0f5e87ed25778eeb8318e89cdad4d67ed6c
-libraries_bom_version: 26.59.0
+gapic_generator_version: 2.58.0
+googleapis_commitish: f319bbc88abd22cd8c39c349e776cf3dc2722214
+libraries_bom_version: 26.60.0
libraries:
- api_shortname: pubsub
name_pretty: Cloud Pub/Sub
diff --git a/google-cloud-pubsub-bom/pom.xml b/google-cloud-pubsub-bom/pom.xml
index 2751af946..1edcb15cb 100644
--- a/google-cloud-pubsub-bom/pom.xml
+++ b/google-cloud-pubsub-bom/pom.xml
@@ -3,12 +3,12 @@
4.0.0
com.google.cloud
google-cloud-pubsub-bom
- 1.139.3
+ 1.139.4
pom
com.google.cloud
sdk-platform-java-config
- 3.47.0
+ 3.48.0
Google Cloud pubsub BOM
@@ -52,17 +52,17 @@
com.google.cloud
google-cloud-pubsub
- 1.139.3
+ 1.139.4
com.google.api.grpc
grpc-google-cloud-pubsub-v1
- 1.121.3
+ 1.121.4
com.google.api.grpc
proto-google-cloud-pubsub-v1
- 1.121.3
+ 1.121.4
diff --git a/google-cloud-pubsub/pom.xml b/google-cloud-pubsub/pom.xml
index 247d4d388..dd5fe6a55 100644
--- a/google-cloud-pubsub/pom.xml
+++ b/google-cloud-pubsub/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.google.cloud
google-cloud-pubsub
- 1.139.3
+ 1.139.4
jar
Google Cloud Pub/Sub
https://github.com/googleapis/java-pubsub
@@ -11,7 +11,7 @@
com.google.cloud
google-cloud-pubsub-parent
- 1.139.3
+ 1.139.4
google-cloud-pubsub
diff --git a/grpc-google-cloud-pubsub-v1/pom.xml b/grpc-google-cloud-pubsub-v1/pom.xml
index 6f4c9040b..c44258fb1 100644
--- a/grpc-google-cloud-pubsub-v1/pom.xml
+++ b/grpc-google-cloud-pubsub-v1/pom.xml
@@ -4,13 +4,13 @@
4.0.0
com.google.api.grpc
grpc-google-cloud-pubsub-v1
- 1.121.3
+ 1.121.4
grpc-google-cloud-pubsub-v1
GRPC library for grpc-google-cloud-pubsub-v1
com.google.cloud
google-cloud-pubsub-parent
- 1.139.3
+ 1.139.4
diff --git a/pom.xml b/pom.xml
index e64114d54..92ec4902e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
com.google.cloud
google-cloud-pubsub-parent
pom
- 1.139.3
+ 1.139.4
Google Cloud Pub/Sub Parent
https://github.com/googleapis/java-pubsub
@@ -14,7 +14,7 @@
com.google.cloud
sdk-platform-java-config
- 3.47.0
+ 3.48.0
@@ -69,17 +69,17 @@
com.google.api.grpc
proto-google-cloud-pubsub-v1
- 1.121.3
+ 1.121.4
com.google.api.grpc
grpc-google-cloud-pubsub-v1
- 1.121.3
+ 1.121.4
com.google.cloud
google-cloud-pubsub
- 1.139.3
+ 1.139.4
diff --git a/proto-google-cloud-pubsub-v1/pom.xml b/proto-google-cloud-pubsub-v1/pom.xml
index 250da2b16..0586560ae 100644
--- a/proto-google-cloud-pubsub-v1/pom.xml
+++ b/proto-google-cloud-pubsub-v1/pom.xml
@@ -4,13 +4,13 @@
4.0.0
com.google.api.grpc
proto-google-cloud-pubsub-v1
- 1.121.3
+ 1.121.4
proto-google-cloud-pubsub-v1
PROTO library for proto-google-cloud-pubsub-v1
com.google.cloud
google-cloud-pubsub-parent
- 1.139.3
+ 1.139.4
diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml
index 2c150fbdb..b73774790 100644
--- a/samples/install-without-bom/pom.xml
+++ b/samples/install-without-bom/pom.xml
@@ -44,7 +44,7 @@
com.google.cloud
google-cloud-pubsub
- 1.139.1
+ 1.139.3
@@ -80,23 +80,23 @@
com.google.cloud
google-cloud-core
- 2.54.3
+ 2.56.0
tests
com.google.cloud
google-cloud-bigquery
- 2.49.2
+ 2.50.0
com.google.cloud
google-cloud-storage
- 2.52.1
+ 2.52.2
com.google.cloud.opentelemetry
exporter-trace
- 0.33.0
+ 0.34.0
diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml
index 83aa5078d..267ff17f2 100644
--- a/samples/snapshot/pom.xml
+++ b/samples/snapshot/pom.xml
@@ -43,7 +43,7 @@
com.google.cloud
google-cloud-pubsub
- 1.139.3
+ 1.139.4
@@ -79,23 +79,23 @@
com.google.cloud
google-cloud-core
- 2.54.3
+ 2.56.0
tests
com.google.cloud
google-cloud-bigquery
- 2.49.2
+ 2.50.0
com.google.cloud
google-cloud-storage
- 2.52.1
+ 2.52.2
com.google.cloud.opentelemetry
exporter-trace
- 0.33.0
+ 0.34.0
diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml
index 4b5c90716..c5877a62e 100644
--- a/samples/snippets/pom.xml
+++ b/samples/snippets/pom.xml
@@ -45,7 +45,7 @@
com.google.cloud
libraries-bom
- 26.59.0
+ 26.60.0
pom
import
@@ -70,7 +70,7 @@
com.google.cloud.opentelemetry
exporter-trace
- 0.33.0
+ 0.34.0
org.apache.avro
@@ -103,7 +103,7 @@
com.google.cloud
google-cloud-core
- 2.54.3
+ 2.56.0
tests
diff --git a/samples/snippets/src/main/java/pubsub/CreateSubscriptionWithSmtExample.java b/samples/snippets/src/main/java/pubsub/CreateSubscriptionWithSmtExample.java
new file mode 100644
index 000000000..53516c540
--- /dev/null
+++ b/samples/snippets/src/main/java/pubsub/CreateSubscriptionWithSmtExample.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package pubsub;
+
+// [START pubsub_create_subscription_with_smt]
+import com.google.cloud.pubsub.v1.SubscriptionAdminClient;
+import com.google.pubsub.v1.JavaScriptUDF;
+import com.google.pubsub.v1.MessageTransform;
+import com.google.pubsub.v1.ProjectSubscriptionName;
+import com.google.pubsub.v1.ProjectTopicName;
+import com.google.pubsub.v1.Subscription;
+import java.io.IOException;
+
+public class CreateSubscriptionWithSmtExample {
+ public static void main(String... args) throws Exception {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String topicId = "your-topic-id";
+ String subscriptionId = "your-subscription-id";
+
+ createSubscriptionWithSmtExample(projectId, topicId, subscriptionId);
+ }
+
+ public static void createSubscriptionWithSmtExample(
+ String projectId, String topicId, String subscriptionId) throws IOException {
+
+ // UDF that removes the 'ssn' field, if present
+ String code =
+ "function redactSSN(message, metadata) {"
+ + " const data = JSON.parse(message.data);"
+ + " delete data['ssn'];"
+ + " message.data = JSON.stringify(data);"
+ + " return message;"
+ + "}";
+ String functionName = "redactSSN";
+
+ JavaScriptUDF udf =
+ JavaScriptUDF.newBuilder().setCode(code).setFunctionName(functionName).build();
+ MessageTransform transform = MessageTransform.newBuilder().setJavascriptUdf(udf).build();
+
+ try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
+
+ ProjectTopicName topicName = ProjectTopicName.of(projectId, topicId);
+ ProjectSubscriptionName subscriptionName =
+ ProjectSubscriptionName.of(projectId, subscriptionId);
+
+ Subscription subscription =
+ subscriptionAdminClient.createSubscription(
+ Subscription.newBuilder()
+ .setName(subscriptionName.toString())
+ .setTopic(topicName.toString())
+ // Add the UDF message transform
+ .addMessageTransforms(transform)
+ .build());
+
+ System.out.println("Created subscription with SMT: " + subscription.getAllFields());
+ }
+ }
+}
+// [END pubsub_create_subscription_with_smt]
diff --git a/samples/snippets/src/main/java/pubsub/CreateTopicWithSmtExample.java b/samples/snippets/src/main/java/pubsub/CreateTopicWithSmtExample.java
new file mode 100644
index 000000000..c96322015
--- /dev/null
+++ b/samples/snippets/src/main/java/pubsub/CreateTopicWithSmtExample.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package pubsub;
+
+// [START pubsub_create_topic_with_smt]
+
+import com.google.api.gax.rpc.AlreadyExistsException;
+import com.google.cloud.pubsub.v1.TopicAdminClient;
+import com.google.pubsub.v1.JavaScriptUDF;
+import com.google.pubsub.v1.MessageTransform;
+import com.google.pubsub.v1.Topic;
+import com.google.pubsub.v1.TopicName;
+import java.io.IOException;
+
+public class CreateTopicWithSmtExample {
+
+ public static void main(String... args) throws Exception {
+ // TODO(developer): Replace these variables before running the sample.
+ String projectId = "your-project-id";
+ String topicId = "your-topic-id";
+
+ createTopicWithSmtExample(projectId, topicId);
+ }
+
+ public static void createTopicWithSmtExample(String projectId, String topicId)
+ throws IOException {
+ TopicName topicName = TopicName.of(projectId, topicId);
+
+ // UDF that removes the 'ssn' field, if present
+ String code =
+ "function redactSSN(message, metadata) {"
+ + " const data = JSON.parse(message.data);"
+ + " delete data['ssn'];"
+ + " message.data = JSON.stringify(data);"
+ + " return message;"
+ + "}";
+ String functionName = "redactSSN";
+
+ JavaScriptUDF udf =
+ JavaScriptUDF.newBuilder().setCode(code).setFunctionName(functionName).build();
+ MessageTransform transform = MessageTransform.newBuilder().setJavascriptUdf(udf).build();
+ try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
+
+ Topic topic =
+ topicAdminClient.createTopic(
+ Topic.newBuilder()
+ .setName(topicName.toString())
+ // Add the UDF message transform
+ .addMessageTransforms(transform)
+ .build());
+
+ System.out.println("Created topic with SMT: " + topic.getName());
+ } catch (AlreadyExistsException e) {
+ System.out.println(topicName + "already exists.");
+ }
+ }
+}
+ // [END pubsub_create_topic_with_smt]
diff --git a/samples/snippets/src/test/java/pubsub/AdminIT.java b/samples/snippets/src/test/java/pubsub/AdminIT.java
index accec5126..60c85f340 100644
--- a/samples/snippets/src/test/java/pubsub/AdminIT.java
+++ b/samples/snippets/src/test/java/pubsub/AdminIT.java
@@ -60,10 +60,12 @@ public class AdminIT {
"confluent-cloud-ingestion-topic-" + _suffix;
private static final String azureEventHubsIngestionTopicId =
"azure-event-hubs-ingestion-topic-" + _suffix;
+ private static final String smtTopicId = "smt-topic-" + _suffix;
private static final String pullSubscriptionId = "iam-pull-subscription-" + _suffix;
private static final String pushSubscriptionId = "iam-push-subscription-" + _suffix;
private static final String orderedSubscriptionId = "iam-ordered-subscription-" + _suffix;
private static final String filteredSubscriptionId = "iam-filtered-subscription-" + _suffix;
+ private static final String smtSubscriptionId = "smt-subscription-" + _suffix;
private static final String exactlyOnceSubscriptionId =
"iam-exactly-once-subscription-" + _suffix;
private static final String pushEndpoint = "https://my-test-project.appspot.com/push";
@@ -118,6 +120,7 @@ public class AdminIT {
TopicName.of(projectId, confluentCloudIngestionTopicId);
private static final TopicName azureEventHubsIngestionTopicName =
TopicName.of(projectId, azureEventHubsIngestionTopicId);
+ private static final TopicName smtTopicName = TopicName.of(projectId, smtTopicId);
private static final SubscriptionName pullSubscriptionName =
SubscriptionName.of(projectId, pullSubscriptionId);
private static final SubscriptionName pushSubscriptionName =
@@ -128,6 +131,8 @@ public class AdminIT {
SubscriptionName.of(projectId, filteredSubscriptionId);
private static final SubscriptionName exactlyOnceSubscriptionName =
SubscriptionName.of(projectId, exactlyOnceSubscriptionId);
+ private static final SubscriptionName smtSubscriptionName =
+ SubscriptionName.of(projectId, smtSubscriptionId);
private static void requireEnvVar(String varName) {
assertNotNull(
@@ -456,5 +461,20 @@ public void testAdmin() throws Exception {
// Test delete Azure Event Hubs ingestion topic.
DeleteTopicExample.deleteTopicExample(projectId, azureEventHubsIngestionTopicId);
assertThat(bout.toString()).contains("Deleted topic.");
+
+ bout.reset();
+ // Test create topic with an SMT.
+ CreateTopicWithSmtExample.createTopicWithSmtExample(projectId, smtTopicId);
+ assertThat(bout.toString()).contains("Created topic with SMT: " + smtTopicName.toString());
+
+ bout.reset();
+ // Test create topic with an SMT.
+ CreateSubscriptionWithSmtExample.createSubscriptionWithSmtExample(
+ projectId, smtTopicId, smtSubscriptionId);
+ assertThat(bout.toString()).contains("Created subscription with SMT");
+ assertThat(bout.toString()).contains(smtSubscriptionName.toString());
+ assertThat(bout.toString()).contains("redactSSN");
+ DeleteSubscriptionExample.deleteSubscriptionExample(projectId, smtSubscriptionId);
+ DeleteTopicExample.deleteTopicExample(projectId, smtTopicId);
}
}
diff --git a/versions.txt b/versions.txt
index 67620086f..891e99e9b 100644
--- a/versions.txt
+++ b/versions.txt
@@ -1,6 +1,6 @@
# Format:
# module:released-version:current-version
-google-cloud-pubsub:1.139.3:1.139.3
-grpc-google-cloud-pubsub-v1:1.121.3:1.121.3
-proto-google-cloud-pubsub-v1:1.121.3:1.121.3
+google-cloud-pubsub:1.139.4:1.139.4
+grpc-google-cloud-pubsub-v1:1.121.4:1.121.4
+proto-google-cloud-pubsub-v1:1.121.4:1.121.4