diff --git a/google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/PublisherSnippets.java b/google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/PublisherSnippets.java index 989b7ba96a0f..44104c731c3a 100644 --- a/google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/PublisherSnippets.java +++ b/google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/PublisherSnippets.java @@ -36,6 +36,7 @@ import com.google.pubsub.v1.ProjectTopicName; import com.google.pubsub.v1.PubsubMessage; import java.io.FileInputStream; +import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import org.threeten.bp.Duration; @@ -62,7 +63,7 @@ public void onSuccess(String messageId) { public void onFailure(Throwable t) { System.out.println("failed to publish: " + t); } - }); + }, Executors.newSingleThreadExecutor()); return messageIdFuture; }