GeezerVison is showing github.com (truncated) — add back PubSub samples by pongad · Pull Request #1540 · googleapis/google-cloud-java
Conversation
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
* A snippet for Google Cloud Pub/Sub showing how to create a Pub/Sub pull subscription and
|
|
|
* asynchronously pull messages from it.
|
|
|
*/
|
|
|
public class CreateSubscriptionAndPullMessages {
|
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
subscriberClient.createSubscription(subscription, topic, PushConfig.getDefaultInstance(), 0);
|
|
|
}
|
|
|
|
|
|
MessageReceiver receiver =
|
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
Thread.sleep(60000);
|
|
|
} finally {
|
|
|
if (subscriber != null) {
|
|
|
subscriber.stopAsync();
|
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
@Override
|
|
|
public void failed(Service.State from, Throwable failure) {
|
|
|
System.err.println(failure);
|
|
|
}
|
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
}
|
|
|
},
|
|
|
MoreExecutors.directExecutor());
|
|
|
subscriber.startAsync().awaitRunning();
|
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
for (String message : messages) {
|
|
|
messageIds.add(
|
|
|
publisher.publish(
|
|
|
PubsubMessage.newBuilder().setData(ByteString.copyFromUtf8(message)).build()));
|
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
publisher.publish(
|
|
|
PubsubMessage.newBuilder().setData(ByteString.copyFromUtf8(message)).build()));
|
|
|
}
|
|
|
for (String messageId : Futures.allAsList(messageIds).get()) {
|
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
return new Builder(topic);
|
|
|
}
|
|
|
|
|
|
public static Builder newBuilder(TopicName topic) {
|
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
@@ -142,6 +143,10 @@ public static Builder newBuilder(String subscription, MessageReceiver receiver) |
|
|
return new Builder(subscription, receiver);
|
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
@@ -186,6 +187,10 @@ public static Builder newBuilder(String topic) { |
|
|
return new Builder(topic);
|
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|

Coverage remained the same at 83.113% when pulling 7b2cac7 on pongad:pub-doc into 19acb03 on GoogleCloudPlatform:pubsub-rm.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
for (String message : messages) {
|
|
|
PubsubMessage pubsubMessage =
|
|
|
PubsubMessage.newBuilder().setData(ByteString.copyFromUtf8(message)).build();
|
|
|
messageIds.add(publisher.publish(pubsubMessage));
|
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
LGTM for merging purposes. Add a to do somewhere to make the samples simpler.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
chingor13
pushed a commit
that referenced
this pull request
Jan 22, 2026
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
suztomo
pushed a commit
to suztomo/google-cloud-java
that referenced
this pull request
Mar 23, 2026
suztomo
pushed a commit
to suztomo/google-cloud-java
that referenced
this pull request
Mar 23, 2026
meltsufin
pushed a commit
that referenced
this pull request
Apr 29, 2026
* receipt-modack for exactly once
* changing setup
* changing the pendingReceipt List
* using scheduled fixed rate
* using blocked queues
* using blocked queues
* using blocked queues
* adding null safety
* adding null safety
* removing list
* adding list back
* if permanent failure, remove outstandingmsg from queue
* adding snippet of test
* adding method to streaming subscriber
* adding method to streaming subscriber
* adding notifyAcks
* changing notifyAckFailed calls
* addressing some comments
* changed logic to use one datastructure
* fixing notifyFailed
* fixing notifyFailed
* changing Pair to custom class
* removing the not needed data structure
* Fixing test
* Fixing test
* Fixing test
* Fixing test
* fixing format
* fixing test to call receiveMessage
* testing test failure
* testing test failure
* testing test failure
* increasing timestamp to test
* increasing timestamp to test
* adding log statement for testing
* Fixing lint
* Adding more logs
* batch size log
* changing method to syncronized
* fixing for loop to not remove as we are iterating
* trying a concurrent map
* fix: syncronizing notifyFailed
* fix: removing unused import
* fix: reformat
* 🦉 Updates from OwlBot post-processor
See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md
* fix: removing System.out.println statements
* fix: reviewign comments
* fix: lint
* adding another ordering key test example
* fix: trying to run this test again
* fix: trying to run this test again
* fix: removing commented code
* fix: removing commented code
* resolving the comments from review
* adding custom matcher
* adding custom matcher
* adding custom matcher
* adding custom matcher
* adding custom matcher correcting the matching statement
* lint
* removing comments
* removing comments
* removing comments
* changing messageMatcher to messageDataMatcher, and fixing other nit things
* lint
* addressing review comments
* addressing review comments
---------
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
meltsufin
pushed a commit
that referenced
this pull request
May 1, 2026
* receipt-modack for exactly once
* changing setup
* changing the pendingReceipt List
* using scheduled fixed rate
* using blocked queues
* using blocked queues
* using blocked queues
* adding null safety
* adding null safety
* removing list
* adding list back
* if permanent failure, remove outstandingmsg from queue
* adding snippet of test
* adding method to streaming subscriber
* adding method to streaming subscriber
* adding notifyAcks
* changing notifyAckFailed calls
* addressing some comments
* changed logic to use one datastructure
* fixing notifyFailed
* fixing notifyFailed
* changing Pair to custom class
* removing the not needed data structure
* Fixing test
* Fixing test
* Fixing test
* Fixing test
* fixing format
* fixing test to call receiveMessage
* testing test failure
* testing test failure
* testing test failure
* increasing timestamp to test
* increasing timestamp to test
* adding log statement for testing
* Fixing lint
* Adding more logs
* batch size log
* changing method to syncronized
* fixing for loop to not remove as we are iterating
* trying a concurrent map
* fix: syncronizing notifyFailed
* fix: removing unused import
* fix: reformat
* 🦉 Updates from OwlBot post-processor
See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md
* fix: removing System.out.println statements
* fix: reviewign comments
* fix: lint
* adding another ordering key test example
* fix: trying to run this test again
* fix: trying to run this test again
* fix: removing commented code
* fix: removing commented code
* resolving the comments from review
* adding custom matcher
* adding custom matcher
* adding custom matcher
* adding custom matcher
* adding custom matcher correcting the matching statement
* lint
* removing comments
* removing comments
* removing comments
* changing messageMatcher to messageDataMatcher, and fixing other nit things
* lint
* addressing review comments
* addressing review comments
---------
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
|