Skip to content

Commit

Permalink
Merge branch 'main' into otel-samples
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelpri10 committed Oct 3, 2024
2 parents 45ce9eb + 21d5cfc commit 938e6c7
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 35 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## [1.133.0](https://github.com/googleapis/java-pubsub/compare/v1.132.4...v1.133.0) (2024-10-01)


### Features

* Add OpenTelemetry tracing to the Publisher and Subscriber ([#2086](https://github.com/googleapis/java-pubsub/issues/2086)) ([db522b6](https://github.com/googleapis/java-pubsub/commit/db522b60f1bbec9cc1bfa0c37477044fd2f807c7))


### Dependencies

* Update dependency com.google.cloud.opentelemetry:exporter-trace to v0.32.0 ([#2205](https://github.com/googleapis/java-pubsub/issues/2205)) ([76f17e4](https://github.com/googleapis/java-pubsub/commit/76f17e4149bf369f2be12fe9d316a23a7f49f137))
* Update dependency org.assertj:assertj-core to v3.26.3 ([#2204](https://github.com/googleapis/java-pubsub/issues/2204)) ([71c2e76](https://github.com/googleapis/java-pubsub/commit/71c2e762e94895c465c4e737ed8bf7bc583a9c14))

## [1.132.4](https://github.com/googleapis/java-pubsub/compare/v1.132.3...v1.132.4) (2024-09-30)


Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ 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.132.4'
implementation 'com.google.cloud:google-cloud-pubsub:1.133.0'
```

If you are using SBT, add this to your dependencies:

```Scala
libraryDependencies += "com.google.cloud" % "google-cloud-pubsub" % "1.132.4"
libraryDependencies += "com.google.cloud" % "google-cloud-pubsub" % "1.133.0"
```
<!-- {x-version-update-end} -->

Expand Down Expand Up @@ -414,7 +414,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.132.4
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-pubsub/1.133.0
[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
Expand Down
8 changes: 4 additions & 4 deletions google-cloud-pubsub-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub-bom</artifactId>
<version>1.132.5-SNAPSHOT</version><!-- {x-version-update:google-cloud-pubsub:current} -->
<version>1.133.0</version><!-- {x-version-update:google-cloud-pubsub:current} -->
<packaging>pom</packaging>
<parent>
<groupId>com.google.cloud</groupId>
Expand Down Expand Up @@ -52,17 +52,17 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
<version>1.132.5-SNAPSHOT</version><!-- {x-version-update:google-cloud-pubsub:current} -->
<version>1.133.0</version><!-- {x-version-update:google-cloud-pubsub:current} -->
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-cloud-pubsub-v1</artifactId>
<version>1.114.5-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-pubsub-v1:current} -->
<version>1.115.0</version><!-- {x-version-update:grpc-google-cloud-pubsub-v1:current} -->
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-cloud-pubsub-v1</artifactId>
<version>1.114.5-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-pubsub-v1:current} -->
<version>1.115.0</version><!-- {x-version-update:proto-google-cloud-pubsub-v1:current} -->
</dependency>
</dependencies>
</dependencyManagement>
Expand Down
4 changes: 2 additions & 2 deletions google-cloud-pubsub/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
<version>1.132.5-SNAPSHOT</version><!-- {x-version-update:google-cloud-pubsub:current} -->
<version>1.133.0</version><!-- {x-version-update:google-cloud-pubsub:current} -->
<packaging>jar</packaging>
<name>Google Cloud Pub/Sub</name>
<url>https://github.com/googleapis/java-pubsub</url>
<description>Java idiomatic client for Google Cloud Pub/Sub</description>
<parent>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub-parent</artifactId>
<version>1.132.5-SNAPSHOT</version><!-- {x-version-update:google-cloud-pubsub:current} -->
<version>1.133.0</version><!-- {x-version-update:google-cloud-pubsub:current} -->
</parent>
<properties>
<site.installationModule>google-cloud-pubsub</site.installationModule>
Expand Down
4 changes: 2 additions & 2 deletions grpc-google-cloud-pubsub-v1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-cloud-pubsub-v1</artifactId>
<version>1.114.5-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-pubsub-v1:current} -->
<version>1.115.0</version><!-- {x-version-update:grpc-google-cloud-pubsub-v1:current} -->
<name>grpc-google-cloud-pubsub-v1</name>
<description>GRPC library for grpc-google-cloud-pubsub-v1</description>
<parent>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub-parent</artifactId>
<version>1.132.5-SNAPSHOT</version><!-- {x-version-update:google-cloud-pubsub:current} -->
<version>1.133.0</version><!-- {x-version-update:google-cloud-pubsub:current} -->
</parent>
<dependencies>
<dependency>
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub-parent</artifactId>
<packaging>pom</packaging>
<version>1.132.5-SNAPSHOT</version><!-- {x-version-update:google-cloud-pubsub:current} -->
<version>1.133.0</version><!-- {x-version-update:google-cloud-pubsub:current} -->
<name>Google Cloud Pub/Sub Parent</name>
<url>https://github.com/googleapis/java-pubsub</url>
<description>
Expand Down Expand Up @@ -69,17 +69,17 @@
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-cloud-pubsub-v1</artifactId>
<version>1.114.5-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-pubsub-v1:current} -->
<version>1.115.0</version><!-- {x-version-update:proto-google-cloud-pubsub-v1:current} -->
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-cloud-pubsub-v1</artifactId>
<version>1.114.5-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-pubsub-v1:current} -->
<version>1.115.0</version><!-- {x-version-update:grpc-google-cloud-pubsub-v1:current} -->
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
<version>1.132.5-SNAPSHOT</version><!-- {x-version-update:google-cloud-pubsub:current} -->
<version>1.133.0</version><!-- {x-version-update:google-cloud-pubsub:current} -->
</dependency>

<!-- Test dependencies -->
Expand Down
4 changes: 2 additions & 2 deletions proto-google-cloud-pubsub-v1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-cloud-pubsub-v1</artifactId>
<version>1.114.5-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-pubsub-v1:current} -->
<version>1.115.0</version><!-- {x-version-update:proto-google-cloud-pubsub-v1:current} -->
<name>proto-google-cloud-pubsub-v1</name>
<description>PROTO library for proto-google-cloud-pubsub-v1</description>
<parent>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub-parent</artifactId>
<version>1.132.5-SNAPSHOT</version><!-- {x-version-update:google-cloud-pubsub:current} -->
<version>1.133.0</version><!-- {x-version-update:google-cloud-pubsub:current} -->
</parent>
<dependencies>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion samples/install-without-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
<version>1.132.3</version>
<version>1.133.0</version>
</dependency>
<!-- [END pubsub_install_without_bom] -->

Expand Down
2 changes: 1 addition & 1 deletion samples/snapshot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
<version>1.132.5-SNAPSHOT</version>
<version>1.133.0</version>
</dependency>
<!-- {x-version-update-end} -->

Expand Down
2 changes: 1 addition & 1 deletion samples/snippets/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>26.47.0</version>
<version>26.48.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
40 changes: 28 additions & 12 deletions samples/snippets/src/main/java/pubsub/UsePubSubEmulatorExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@

package pubsub;

/**
* Snippet that demonstrates creating Pub/Sub clients using the Google Cloud Pub/Sub emulator.
*
* <p>Note: clients cannot start/stop the emulator.
*/

// [START pubsub_use_emulator]

import com.google.api.core.ApiFuture;
import com.google.api.gax.core.CredentialsProvider;
import com.google.api.gax.core.NoCredentialsProvider;
import com.google.api.gax.grpc.GrpcTransportChannel;
Expand All @@ -24,20 +33,16 @@
import com.google.cloud.pubsub.v1.Publisher;
import com.google.cloud.pubsub.v1.TopicAdminClient;
import com.google.cloud.pubsub.v1.TopicAdminSettings;
import com.google.protobuf.ByteString;
import com.google.pubsub.v1.PubsubMessage;
import com.google.pubsub.v1.Topic;
import com.google.pubsub.v1.TopicName;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import java.io.IOException;

/**
* Snippet that demonstrates creating Pub/Sub clients using the Google Cloud Pub/Sub emulator.
*
* <p>Note: clients cannot start/stop the emulator.
*/
public class UsePubSubEmulatorExample {

public static void main(String... args) throws IOException {
// [START pubsub_use_emulator]
public static void main(String... args) throws Exception {
String hostport = System.getenv("PUBSUB_EMULATOR_HOST");
ManagedChannel channel = ManagedChannelBuilder.forTarget(hostport).usePlaintext().build();
try {
Expand All @@ -46,25 +51,36 @@ public static void main(String... args) throws IOException {
CredentialsProvider credentialsProvider = NoCredentialsProvider.create();

// Set the channel and credentials provider when creating a `TopicAdminClient`.
// Similarly for SubscriptionAdminClient
TopicAdminClient topicClient =
// Can be done similarly for a `SubscriptionAdminClient`.
TopicAdminClient topicAdminClient =
TopicAdminClient.create(
TopicAdminSettings.newBuilder()
.setTransportChannelProvider(channelProvider)
.setCredentialsProvider(credentialsProvider)
.build());

TopicName topicName = TopicName.of("my-project-id", "my-topic-id");
Topic topic = topicAdminClient.createTopic(topicName);
System.out.println("Created topic: " + topic.getName());

// Set the channel and credentials provider when creating a `Publisher`.
// Similarly for Subscriber
// Can be done similarly for a `Subscriber`.
Publisher publisher =
Publisher.newBuilder(topicName)
.setChannelProvider(channelProvider)
.setCredentialsProvider(credentialsProvider)
.build();

String message = "Hello World!";
ByteString data = ByteString.copyFromUtf8(message);
PubsubMessage pubsubMessage = PubsubMessage.newBuilder().setData(data).build();

ApiFuture<String> messageIdFuture = publisher.publish(pubsubMessage);
String messageId = messageIdFuture.get();
System.out.println("Published message ID: " + messageId);
} finally {
channel.shutdown();
}
// [END pubsub_use_emulator]
}
}
// [END pubsub_use_emulator]
6 changes: 3 additions & 3 deletions versions.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Format:
# module:released-version:current-version

google-cloud-pubsub:1.132.4:1.132.5-SNAPSHOT
grpc-google-cloud-pubsub-v1:1.114.4:1.114.5-SNAPSHOT
proto-google-cloud-pubsub-v1:1.114.4:1.114.5-SNAPSHOT
google-cloud-pubsub:1.133.0:1.133.0
grpc-google-cloud-pubsub-v1:1.115.0:1.115.0
proto-google-cloud-pubsub-v1:1.115.0:1.115.0

0 comments on commit 938e6c7

Please sign in to comment.