@BetaApi @Generated(value="by gapic-generator") public class PublisherServiceClient extends Object implements com.google.api.gax.core.BackgroundResource
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
Note: close() needs to be called on the PublisherServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of PublisherServiceSettings to create(). For example:
To customize credentials:
PublisherServiceSettings publisherServiceSettings =
PublisherServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
PublisherServiceClient publisherServiceClient =
PublisherServiceClient.create(publisherServiceSettings);
To customize the endpoint:
PublisherServiceSettings publisherServiceSettings =
PublisherServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
PublisherServiceClient publisherServiceClient =
PublisherServiceClient.create(publisherServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
| Modifier | Constructor and Description |
|---|---|
protected |
PublisherServiceClient(PublisherServiceSettings settings)
Constructs an instance of PublisherServiceClient, using the given settings.
|
protected |
PublisherServiceClient(PublisherServiceStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static PublisherServiceClient |
create()
Constructs an instance of PublisherServiceClient with default settings.
|
static PublisherServiceClient |
create(PublisherServiceSettings settings)
Constructs an instance of PublisherServiceClient, using the given settings.
|
static PublisherServiceClient |
create(PublisherServiceStub stub)
Constructs an instance of PublisherServiceClient, using the given stub for making calls.
|
PublisherServiceSettings |
getSettings() |
PublisherServiceStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
com.google.api.gax.rpc.BidiStreamingCallable<PublishRequest,PublishResponse> |
publishCallable()
Establishes a stream with the server for publishing messages.
|
void |
shutdown() |
void |
shutdownNow() |
protected PublisherServiceClient(PublisherServiceSettings settings) throws IOException
IOException@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected PublisherServiceClient(PublisherServiceStub stub)
public static final PublisherServiceClient create() throws IOException
IOExceptionpublic static final PublisherServiceClient create(PublisherServiceSettings settings) throws IOException
IOException@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final PublisherServiceClient create(PublisherServiceStub stub)
public final PublisherServiceSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public PublisherServiceStub getStub()
public final com.google.api.gax.rpc.BidiStreamingCallable<PublishRequest,PublishResponse> publishCallable()
Sample code:
public final void close()
close in interface AutoCloseablepublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2021 Google LLC. All rights reserved.