Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e2165af

Browse filesBrowse files
authored
pubsub: clarify sleep-then-stop in snippet (googleapis#2617)
Fixes googleapis#2616
1 parent a8309e5 commit e2165af
Copy full SHA for e2165af

1 file changed

+4-1Lines changed: 4 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/CreateSubscriptionAndConsumeMessages.java‎

Copy file name to clipboardExpand all lines: google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/CreateSubscriptionAndConsumeMessages.java
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,13 @@ public void failed(Subscriber.State from, Throwable failure) {
6262
MoreExecutors.directExecutor());
6363
subscriber.startAsync().awaitRunning();
6464

65+
// In this example, we will pull messages for one minute (60,000ms) then stop.
66+
// In a real application, this sleep-then-stop is not necessary.
67+
// Simply call stopAsync().awaitTerminated() when the server is shutting down, etc.
6568
Thread.sleep(60000);
6669
} finally {
6770
if (subscriber != null) {
68-
subscriber.stopAsync();
71+
subscriber.stopAsync().awaitTerminated();
6972
}
7073
}
7174
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.