Package com.google.cloud.pubsublite.v1 (1.12.22)

A client to Pub/Sub Lite API

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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PublisherServiceClient publisherServiceClient = PublisherServiceClient.create()) {
   BidiStream<PublishRequest, PublishResponse> bidiStream =
       publisherServiceClient.publishCallable().call();
   PublishRequest request = PublishRequest.newBuilder().build();
   bidiStream.send(request);
   for (PublishResponse response : bidiStream) {
     // Do something when a response is received.
   }
 }
 

SubscriberServiceClient

Service Description: The service that a subscriber client application uses to receive messages from subscriptions.

Sample for SubscriberServiceClient:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (SubscriberServiceClient subscriberServiceClient = SubscriberServiceClient.create()) {
   BidiStream<SubscribeRequest, SubscribeResponse> bidiStream =
       subscriberServiceClient.subscribeCallable().call();
   SubscribeRequest request = SubscribeRequest.newBuilder().build();
   bidiStream.send(request);
   for (SubscribeResponse response : bidiStream) {
     // Do something when a response is received.
   }
 }
 

PartitionAssignmentServiceClient

Service Description: The service that a subscriber client application uses to determine which partitions it should connect to.

Sample for PartitionAssignmentServiceClient:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PartitionAssignmentServiceClient partitionAssignmentServiceClient =
     PartitionAssignmentServiceClient.create()) {
   BidiStream<PartitionAssignmentRequest, PartitionAssignment> bidiStream =
       partitionAssignmentServiceClient.assignPartitionsCallable().call();
   PartitionAssignmentRequest request = PartitionAssignmentRequest.newBuilder().build();
   bidiStream.send(request);
   for (PartitionAssignment response : bidiStream) {
     // Do something when a response is received.
   }
 }
 

TopicStatsServiceClient

Service Description: This service allows users to get stats about messages in their topic.

Sample for TopicStatsServiceClient:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 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().

Methods
MethodDescriptionMethod Variants

CreateTopic

Creates a new topic.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createTopic(CreateTopicRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • createTopic(LocationName parent, Topic topic, String topicId)

  • createTopic(String parent, Topic topic, String topicId)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createTopicCallable()

GetTopic

Returns the topic configuration.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getTopic(GetTopicRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getTopic(TopicName name)

  • getTopic(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getTopicCallable()

GetTopicPartitions

Returns the partition information for the requested topic.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getTopicPartitions(GetTopicPartitionsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getTopicPartitions(TopicName name)

  • getTopicPartitions(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getTopicPartitionsCallable()

ListTopics

Returns the list of topics for the given project.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listTopics(ListTopicsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listTopics(LocationName parent)

  • listTopics(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listTopicsPagedCallable()

  • listTopicsCallable()

UpdateTopic

Updates properties of the specified topic.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateTopic(UpdateTopicRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • updateTopic(Topic topic, FieldMask updateMask)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateTopicCallable()

DeleteTopic

Deletes the specified topic.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteTopic(DeleteTopicRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deleteTopic(TopicName name)

  • deleteTopic(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteTopicCallable()

ListTopicSubscriptions

Lists the subscriptions attached to the specified topic.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listTopicSubscriptions(ListTopicSubscriptionsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listTopicSubscriptions(TopicName name)

  • listTopicSubscriptions(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listTopicSubscriptionsPagedCallable()

  • listTopicSubscriptionsCallable()

CreateSubscription

Creates a new subscription.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createSubscription(CreateSubscriptionRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • createSubscription(LocationName parent, Subscription subscription, String subscriptionId)

  • createSubscription(String parent, Subscription subscription, String subscriptionId)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createSubscriptionCallable()

GetSubscription

Returns the subscription configuration.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getSubscription(GetSubscriptionRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getSubscription(SubscriptionName name)

  • getSubscription(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getSubscriptionCallable()

ListSubscriptions

Returns the list of subscriptions for the given project.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listSubscriptions(ListSubscriptionsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listSubscriptions(LocationName parent)

  • listSubscriptions(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listSubscriptionsPagedCallable()

  • listSubscriptionsCallable()

UpdateSubscription

Updates properties of the specified subscription.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateSubscription(UpdateSubscriptionRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • updateSubscription(Subscription subscription, FieldMask updateMask)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateSubscriptionCallable()

DeleteSubscription

Deletes the specified subscription.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteSubscription(DeleteSubscriptionRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deleteSubscription(SubscriptionName name)

  • deleteSubscription(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteSubscriptionCallable()

SeekSubscription

Performs an out-of-band seek for a subscription to a specified target, which may be timestamps or named positions within the message backlog. Seek translates these targets to cursors for each partition and orchestrates subscribers to start consuming messages from these seek cursors.

If an operation is returned, the seek has been registered and subscribers will eventually receive messages from the seek cursors (i.e. eventual consistency), as long as they are using a minimum supported client library version and not a system that tracks cursors independently of Pub/Sub Lite (e.g. Apache Beam, Dataflow, Spark). The seek operation will fail for unsupported clients.

If clients would like to know when subscribers react to the seek (or not), they can poll the operation. The seek operation will succeed and complete once subscribers are ready to receive messages from the seek cursors for all partitions of the topic. This means that the seek operation will not complete until all subscribers come online.

If the previous seek operation has not yet completed, it will be aborted and the new invocation of seek will supersede it.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • seekSubscriptionAsync(SeekSubscriptionRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • seekSubscriptionOperationCallable()

  • seekSubscriptionCallable()

CreateReservation

Creates a new reservation.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createReservation(CreateReservationRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • createReservation(LocationName parent, Reservation reservation, String reservationId)

  • createReservation(String parent, Reservation reservation, String reservationId)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createReservationCallable()

GetReservation

Returns the reservation configuration.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getReservation(GetReservationRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getReservation(ReservationName name)

  • getReservation(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getReservationCallable()

ListReservations

Returns the list of reservations for the given project.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listReservations(ListReservationsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listReservations(LocationName parent)

  • listReservations(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listReservationsPagedCallable()

  • listReservationsCallable()

UpdateReservation

Updates properties of the specified reservation.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateReservation(UpdateReservationRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • updateReservation(Reservation reservation, FieldMask updateMask)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateReservationCallable()

DeleteReservation

Deletes the specified reservation.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteReservation(DeleteReservationRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deleteReservation(ReservationName name)

  • deleteReservation(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteReservationCallable()

ListReservationTopics

Lists the topics attached to the specified reservation.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listReservationTopics(ListReservationTopicsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listReservationTopics(ReservationName name)

  • listReservationTopics(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listReservationTopicsPagedCallable()

  • listReservationTopicsCallable()

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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 AdminServiceSettings adminServiceSettings =
     AdminServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 AdminServiceClient adminServiceClient = AdminServiceClient.create(adminServiceSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 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().

Methods
MethodDescriptionMethod Variants

StreamingCommitCursor

Establishes a stream with the server for managing committed cursors.

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • streamingCommitCursorCallable()

CommitCursor

Updates the committed cursor.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • commitCursor(CommitCursorRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • commitCursorCallable()

ListPartitionCursors

Returns all committed cursor information for a subscription.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listPartitionCursors(ListPartitionCursorsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listPartitionCursors(SubscriptionName parent)

  • listPartitionCursors(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listPartitionCursorsPagedCallable()

  • listPartitionCursorsCallable()

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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 CursorServiceSettings cursorServiceSettings =
     CursorServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 CursorServiceClient cursorServiceClient = CursorServiceClient.create(cursorServiceSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PartitionAssignmentServiceClient partitionAssignmentServiceClient =
     PartitionAssignmentServiceClient.create()) {
   BidiStream<PartitionAssignmentRequest, PartitionAssignment> bidiStream =
       partitionAssignmentServiceClient.assignPartitionsCallable().call();
   PartitionAssignmentRequest request = PartitionAssignmentRequest.newBuilder().build();
   bidiStream.send(request);
   for (PartitionAssignment response : bidiStream) {
     // Do something when a response is received.
   }
 }
 

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().

Methods
MethodDescriptionMethod Variants

AssignPartitions

Assign partitions for this client to handle for the specified subscription.

The client must send an InitialPartitionAssignmentRequest first. The server will then send at most one unacknowledged PartitionAssignment outstanding on the stream at a time. The client should send a PartitionAssignmentAck after updating the partitions it is connected to to reflect the new assignment.

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • assignPartitionsCallable()

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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 PartitionAssignmentServiceSettings partitionAssignmentServiceSettings =
     PartitionAssignmentServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 PartitionAssignmentServiceClient partitionAssignmentServiceClient =
     PartitionAssignmentServiceClient.create(partitionAssignmentServiceSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (PublisherServiceClient publisherServiceClient = PublisherServiceClient.create()) {
   BidiStream<PublishRequest, PublishResponse> bidiStream =
       publisherServiceClient.publishCallable().call();
   PublishRequest request = PublishRequest.newBuilder().build();
   bidiStream.send(request);
   for (PublishResponse response : bidiStream) {
     // Do something when a response is received.
   }
 }
 

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().

Methods
MethodDescriptionMethod Variants

Publish

Establishes a stream with the server for publishing messages. Once the stream is initialized, the client publishes messages by sending publish requests on the stream. The server responds with a PublishResponse for each PublishRequest sent by the client, in the same order that the requests were sent. Note that multiple PublishRequests can be in flight simultaneously, but they will be processed by the server in the order that they are sent by the client on a given stream.

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • publishCallable()

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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 PublisherServiceSettings publisherServiceSettings =
     PublisherServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 PublisherServiceClient publisherServiceClient =
     PublisherServiceClient.create(publisherServiceSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (SubscriberServiceClient subscriberServiceClient = SubscriberServiceClient.create()) {
   BidiStream<SubscribeRequest, SubscribeResponse> bidiStream =
       subscriberServiceClient.subscribeCallable().call();
   SubscribeRequest request = SubscribeRequest.newBuilder().build();
   bidiStream.send(request);
   for (SubscribeResponse response : bidiStream) {
     // Do something when a response is received.
   }
 }
 

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().

Methods
MethodDescriptionMethod Variants

Subscribe

Establishes a stream with the server for receiving messages.

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • subscribeCallable()

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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 SubscriberServiceSettings subscriberServiceSettings =
     SubscriberServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 SubscriberServiceClient subscriberServiceClient =
     SubscriberServiceClient.create(subscriberServiceSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 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().

Methods
MethodDescriptionMethod Variants

ComputeMessageStats

Compute statistics about a range of messages in a given topic and partition.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • computeMessageStats(ComputeMessageStatsRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • computeMessageStatsCallable()

ComputeHeadCursor

Compute the head cursor for the partition. The head cursor's offset is guaranteed to be less than or equal to all messages which have not yet been acknowledged as published, and greater than the offset of any message whose publish has already been acknowledged. It is zero if there have never been messages in the partition.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • computeHeadCursor(ComputeHeadCursorRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • computeHeadCursorCallable()

ComputeTimeCursor

Compute the corresponding cursor for a publish or event time in a topic partition.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • computeTimeCursor(ComputeTimeCursorRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • computeTimeCursorCallable()

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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 TopicStatsServiceSettings topicStatsServiceSettings =
     TopicStatsServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 TopicStatsServiceClient topicStatsServiceClient =
     TopicStatsServiceClient.create(topicStatsServiceSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 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:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 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.