The interfaces provided are listed below, along with usage samples.
AdminServiceClient
Service Description: The service that a client application uses to manage topics and subscriptions, such creating, listing, and deleting topics and subscriptions.
Sample for AdminServiceClient:
try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Topic topic = Topic.newBuilder().build();
String topicId = "topicId-1139259734";
Topic response = adminServiceClient.createTopic(parent, topic, topicId);
}
CursorServiceClient
Service Description: The service that a subscriber client application uses to manage committed cursors while receiving messsages. A cursor represents a subscriber's progress within a topic partition for a given subscription.
Sample for CursorServiceClient:
try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
CommitCursorRequest request =
CommitCursorRequest.newBuilder()
.setSubscription("subscription341203229")
.setPartition(-1799810326)
.setCursor(Cursor.newBuilder().build())
.build();
CommitCursorResponse response = cursorServiceClient.commitCursor(request);
}
PublisherServiceClient
Service Description: The service that a publisher client application uses to publish messages
to topics. Published messages are retained by the service for the duration of the retention
period configured for the respective topic, and are delivered to subscriber clients upon request
(via the SubscriberService
).
Sample for PublisherServiceClient:
try (PublisherServiceClient publisherServiceClient = PublisherServiceClient.create()) {
BidiStream
SubscriberServiceClient
Service Description: The service that a subscriber client application uses to receive messages from subscriptions.
Sample for SubscriberServiceClient:
try (SubscriberServiceClient subscriberServiceClient = SubscriberServiceClient.create()) {
BidiStream
PartitionAssignmentServiceClient
Service Description: The service that a subscriber client application uses to determine which partitions it should connect to.
Sample for PartitionAssignmentServiceClient:
try (PartitionAssignmentServiceClient partitionAssignmentServiceClient =
PartitionAssignmentServiceClient.create()) {
BidiStream
TopicStatsServiceClient
Service Description: This service allows users to get stats about messages in their topic.
Sample for TopicStatsServiceClient:
try (TopicStatsServiceClient topicStatsServiceClient = TopicStatsServiceClient.create()) {
ComputeMessageStatsRequest request =
ComputeMessageStatsRequest.newBuilder()
.setTopic(TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]").toString())
.setPartition(-1799810326)
.setStartCursor(Cursor.newBuilder().build())
.setEndCursor(Cursor.newBuilder().build())
.build();
ComputeMessageStatsResponse response = topicStatsServiceClient.computeMessageStats(request);
}
Classes
AdminServiceClient
Service Description: The service that a client application uses to manage topics and subscriptions, such creating, listing, and deleting topics and subscriptions.
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:
try (AdminServiceClient adminServiceClient = AdminServiceClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
Topic topic = Topic.newBuilder().build();
String topicId = "topicId-1139259734";
Topic response = adminServiceClient.createTopic(parent, topic, topicId);
}
Note: close() needs to be called on the AdminServiceClient 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:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.
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 AdminServiceSettings to create(). For example:
To customize credentials:
AdminServiceSettings adminServiceSettings =
AdminServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
AdminServiceClient adminServiceClient = AdminServiceClient.create(adminServiceSettings);
To customize the endpoint:
AdminServiceSettings adminServiceSettings =
AdminServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
AdminServiceClient adminServiceClient = AdminServiceClient.create(adminServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
AdminServiceClient.ListReservationTopicsFixedSizeCollection
AdminServiceClient.ListReservationTopicsPage
AdminServiceClient.ListReservationTopicsPagedResponse
AdminServiceClient.ListReservationsFixedSizeCollection
AdminServiceClient.ListReservationsPage
AdminServiceClient.ListReservationsPagedResponse
AdminServiceClient.ListSubscriptionsFixedSizeCollection
AdminServiceClient.ListSubscriptionsPage
AdminServiceClient.ListSubscriptionsPagedResponse
AdminServiceClient.ListTopicSubscriptionsFixedSizeCollection
AdminServiceClient.ListTopicSubscriptionsPage
AdminServiceClient.ListTopicSubscriptionsPagedResponse
AdminServiceClient.ListTopicsFixedSizeCollection
AdminServiceClient.ListTopicsPage
AdminServiceClient.ListTopicsPagedResponse
AdminServiceSettings
Settings class to configure an instance of AdminServiceClient.
The default instance has everything set to sensible defaults:
- The default service address (pubsublite.googleapis.com) and default port (443) are used.
- Credentials are acquired automatically through Application Default Credentials.
- Retries are configured for idempotent methods but not for non-idempotent methods.
The builder of this class is recursive, so contained classes are themselves builders. When build() is called, the tree of builders is called to create the complete settings object.
For example, to set the total timeout of createTopic to 30 seconds:
AdminServiceSettings.Builder adminServiceSettingsBuilder = AdminServiceSettings.newBuilder();
adminServiceSettingsBuilder
.createTopicSettings()
.setRetrySettings(
adminServiceSettingsBuilder
.createTopicSettings()
.getRetrySettings()
.toBuilder()
.setTotalTimeout(Duration.ofSeconds(30))
.build());
AdminServiceSettings adminServiceSettings = adminServiceSettingsBuilder.build();
AdminServiceSettings.Builder
Builder for AdminServiceSettings.
CursorServiceClient
Service Description: The service that a subscriber client application uses to manage committed cursors while receiving messsages. A cursor represents a subscriber's progress within a topic partition for a given subscription.
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:
try (CursorServiceClient cursorServiceClient = CursorServiceClient.create()) {
CommitCursorRequest request =
CommitCursorRequest.newBuilder()
.setSubscription("subscription341203229")
.setPartition(-1799810326)
.setCursor(Cursor.newBuilder().build())
.build();
CommitCursorResponse response = cursorServiceClient.commitCursor(request);
}
Note: close() needs to be called on the CursorServiceClient 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:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.
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 CursorServiceSettings to create(). For example:
To customize credentials:
CursorServiceSettings cursorServiceSettings =
CursorServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
CursorServiceClient cursorServiceClient = CursorServiceClient.create(cursorServiceSettings);
To customize the endpoint:
CursorServiceSettings cursorServiceSettings =
CursorServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
CursorServiceClient cursorServiceClient = CursorServiceClient.create(cursorServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
CursorServiceClient.ListPartitionCursorsFixedSizeCollection
CursorServiceClient.ListPartitionCursorsPage
CursorServiceClient.ListPartitionCursorsPagedResponse
CursorServiceSettings
Settings class to configure an instance of CursorServiceClient.
The default instance has everything set to sensible defaults:
- The default service address (pubsublite.googleapis.com) and default port (443) are used.
- Credentials are acquired automatically through Application Default Credentials.
- Retries are configured for idempotent methods but not for non-idempotent methods.
The builder of this class is recursive, so contained classes are themselves builders. When build() is called, the tree of builders is called to create the complete settings object.
For example, to set the total timeout of commitCursor to 30 seconds:
CursorServiceSettings.Builder cursorServiceSettingsBuilder = CursorServiceSettings.newBuilder();
cursorServiceSettingsBuilder
.commitCursorSettings()
.setRetrySettings(
cursorServiceSettingsBuilder
.commitCursorSettings()
.getRetrySettings()
.toBuilder()
.setTotalTimeout(Duration.ofSeconds(30))
.build());
CursorServiceSettings cursorServiceSettings = cursorServiceSettingsBuilder.build();
CursorServiceSettings.Builder
Builder for CursorServiceSettings.
PartitionAssignmentServiceClient
Service Description: The service that a subscriber client application uses to determine which partitions it should connect to.
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:
try (PartitionAssignmentServiceClient partitionAssignmentServiceClient =
PartitionAssignmentServiceClient.create()) {
BidiStream
Note: close() needs to be called on the PartitionAssignmentServiceClient 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:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.
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 PartitionAssignmentServiceSettings to create(). For example:
To customize credentials:
PartitionAssignmentServiceSettings partitionAssignmentServiceSettings =
PartitionAssignmentServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
PartitionAssignmentServiceClient partitionAssignmentServiceClient =
PartitionAssignmentServiceClient.create(partitionAssignmentServiceSettings);
To customize the endpoint:
PartitionAssignmentServiceSettings partitionAssignmentServiceSettings =
PartitionAssignmentServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
PartitionAssignmentServiceClient partitionAssignmentServiceClient =
PartitionAssignmentServiceClient.create(partitionAssignmentServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
PartitionAssignmentServiceSettings
Settings class to configure an instance of PartitionAssignmentServiceClient.
The default instance has everything set to sensible defaults:
- The default service address (pubsublite.googleapis.com) and default port (443) are used.
- Credentials are acquired automatically through Application Default Credentials.
- Retries are configured for idempotent methods but not for non-idempotent methods.
The builder of this class is recursive, so contained classes are themselves builders. When build() is called, the tree of builders is called to create the complete settings object.
For example, to set the total timeout of assignPartitions to 30 seconds:
PartitionAssignmentServiceSettings.Builder partitionAssignmentServiceSettingsBuilder =
PartitionAssignmentServiceSettings.newBuilder();
partitionAssignmentServiceSettingsBuilder
.assignPartitionsSettings()
.setRetrySettings(
partitionAssignmentServiceSettingsBuilder
.assignPartitionsSettings()
.getRetrySettings()
.toBuilder()
.setTotalTimeout(Duration.ofSeconds(30))
.build());
PartitionAssignmentServiceSettings partitionAssignmentServiceSettings =
partitionAssignmentServiceSettingsBuilder.build();
PartitionAssignmentServiceSettings.Builder
Builder for PartitionAssignmentServiceSettings.
PublisherServiceClient
Service Description: The service that a publisher client application uses to publish messages to
topics. Published messages are retained by the service for the duration of the retention period
configured for the respective topic, and are delivered to subscriber clients upon request (via
the SubscriberService
).
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:
try (PublisherServiceClient publisherServiceClient = PublisherServiceClient.create()) {
BidiStream
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:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.
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.
PublisherServiceSettings
Settings class to configure an instance of PublisherServiceClient.
The default instance has everything set to sensible defaults:
- The default service address (pubsublite.googleapis.com) and default port (443) are used.
- Credentials are acquired automatically through Application Default Credentials.
- Retries are configured for idempotent methods but not for non-idempotent methods.
The builder of this class is recursive, so contained classes are themselves builders. When build() is called, the tree of builders is called to create the complete settings object.
For example, to set the total timeout of publish to 30 seconds:
PublisherServiceSettings.Builder publisherServiceSettingsBuilder =
PublisherServiceSettings.newBuilder();
publisherServiceSettingsBuilder
.publishSettings()
.setRetrySettings(
publisherServiceSettingsBuilder
.publishSettings()
.getRetrySettings()
.toBuilder()
.setTotalTimeout(Duration.ofSeconds(30))
.build());
PublisherServiceSettings publisherServiceSettings = publisherServiceSettingsBuilder.build();
PublisherServiceSettings.Builder
Builder for PublisherServiceSettings.
SubscriberServiceClient
Service Description: The service that a subscriber client application uses to receive messages from subscriptions.
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:
try (SubscriberServiceClient subscriberServiceClient = SubscriberServiceClient.create()) {
BidiStream
Note: close() needs to be called on the SubscriberServiceClient 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:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.
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 SubscriberServiceSettings to create(). For example:
To customize credentials:
SubscriberServiceSettings subscriberServiceSettings =
SubscriberServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
SubscriberServiceClient subscriberServiceClient =
SubscriberServiceClient.create(subscriberServiceSettings);
To customize the endpoint:
SubscriberServiceSettings subscriberServiceSettings =
SubscriberServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
SubscriberServiceClient subscriberServiceClient =
SubscriberServiceClient.create(subscriberServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
SubscriberServiceSettings
Settings class to configure an instance of SubscriberServiceClient.
The default instance has everything set to sensible defaults:
- The default service address (pubsublite.googleapis.com) and default port (443) are used.
- Credentials are acquired automatically through Application Default Credentials.
- Retries are configured for idempotent methods but not for non-idempotent methods.
The builder of this class is recursive, so contained classes are themselves builders. When build() is called, the tree of builders is called to create the complete settings object.
For example, to set the total timeout of subscribe to 30 seconds:
SubscriberServiceSettings.Builder subscriberServiceSettingsBuilder =
SubscriberServiceSettings.newBuilder();
subscriberServiceSettingsBuilder
.subscribeSettings()
.setRetrySettings(
subscriberServiceSettingsBuilder
.subscribeSettings()
.getRetrySettings()
.toBuilder()
.setTotalTimeout(Duration.ofSeconds(30))
.build());
SubscriberServiceSettings subscriberServiceSettings = subscriberServiceSettingsBuilder.build();
SubscriberServiceSettings.Builder
Builder for SubscriberServiceSettings.
TopicStatsServiceClient
Service Description: This service allows users to get stats about messages in their topic.
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:
try (TopicStatsServiceClient topicStatsServiceClient = TopicStatsServiceClient.create()) {
ComputeMessageStatsRequest request =
ComputeMessageStatsRequest.newBuilder()
.setTopic(TopicName.of("[PROJECT]", "[LOCATION]", "[TOPIC]").toString())
.setPartition(-1799810326)
.setStartCursor(Cursor.newBuilder().build())
.setEndCursor(Cursor.newBuilder().build())
.build();
ComputeMessageStatsResponse response = topicStatsServiceClient.computeMessageStats(request);
}
Note: close() needs to be called on the TopicStatsServiceClient 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:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.
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 TopicStatsServiceSettings to create(). For example:
To customize credentials:
TopicStatsServiceSettings topicStatsServiceSettings =
TopicStatsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
TopicStatsServiceClient topicStatsServiceClient =
TopicStatsServiceClient.create(topicStatsServiceSettings);
To customize the endpoint:
TopicStatsServiceSettings topicStatsServiceSettings =
TopicStatsServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
TopicStatsServiceClient topicStatsServiceClient =
TopicStatsServiceClient.create(topicStatsServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
TopicStatsServiceSettings
Settings class to configure an instance of TopicStatsServiceClient.
The default instance has everything set to sensible defaults:
- The default service address (pubsublite.googleapis.com) and default port (443) are used.
- Credentials are acquired automatically through Application Default Credentials.
- Retries are configured for idempotent methods but not for non-idempotent methods.
The builder of this class is recursive, so contained classes are themselves builders. When build() is called, the tree of builders is called to create the complete settings object.
For example, to set the total timeout of computeMessageStats to 30 seconds:
TopicStatsServiceSettings.Builder topicStatsServiceSettingsBuilder =
TopicStatsServiceSettings.newBuilder();
topicStatsServiceSettingsBuilder
.computeMessageStatsSettings()
.setRetrySettings(
topicStatsServiceSettingsBuilder
.computeMessageStatsSettings()
.getRetrySettings()
.toBuilder()
.setTotalTimeout(Duration.ofSeconds(30))
.build());
TopicStatsServiceSettings topicStatsServiceSettings = topicStatsServiceSettingsBuilder.build();
TopicStatsServiceSettings.Builder
Builder for TopicStatsServiceSettings.