google-cloud-pubsublite overview (1.11.2) Stay organized with collections Save and categorize content based on your preferences.
com.google.cloud.pubsublite
com.google.cloud.pubsublite.cloudpubsub
com.google.cloud.pubsublite.cloudpubsub.internal
com.google.cloud.pubsublite.internal
com.google.cloud.pubsublite.internal.testing
com.google.cloud.pubsublite.internal.wire
com.google.cloud.pubsublite.proto
com.google.cloud.pubsublite.v1
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_librarytry(AdminServiceClientadminServiceClient=AdminServiceClient.create()){LocationNameparent=LocationName.of("[PROJECT]","[LOCATION]");Topictopic=Topic.newBuilder().build();StringtopicId="topicId-1139259734";Topicresponse=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_librarytry(CursorServiceClientcursorServiceClient=CursorServiceClient.create()){CommitCursorRequestrequest=CommitCursorRequest.newBuilder().setSubscription("subscription341203229").setPartition(-1799810326).setCursor(Cursor.newBuilder().build()).build();CommitCursorResponseresponse=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 theSubscriberService).
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_librarytry(PublisherServiceClientpublisherServiceClient=PublisherServiceClient.create()){BidiStream<PublishRequest,PublishResponse>bidiStream=publisherServiceClient.publishCallable().call();PublishRequestrequest=PublishRequest.newBuilder().build();bidiStream.send(request);for(PublishResponseresponse: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_librarytry(SubscriberServiceClientsubscriberServiceClient=SubscriberServiceClient.create()){BidiStream<SubscribeRequest,SubscribeResponse>bidiStream=subscriberServiceClient.subscribeCallable().call();SubscribeRequestrequest=SubscribeRequest.newBuilder().build();bidiStream.send(request);for(SubscribeResponseresponse: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_librarytry(PartitionAssignmentServiceClientpartitionAssignmentServiceClient=PartitionAssignmentServiceClient.create()){BidiStream<PartitionAssignmentRequest,PartitionAssignment>bidiStream=partitionAssignmentServiceClient.assignPartitionsCallable().call();PartitionAssignmentRequestrequest=PartitionAssignmentRequest.newBuilder().build();bidiStream.send(request);for(PartitionAssignmentresponse: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_librarytry(TopicStatsServiceClienttopicStatsServiceClient=TopicStatsServiceClient.create()){ComputeMessageStatsRequestrequest=ComputeMessageStatsRequest.newBuilder().setTopic(TopicName.of("[PROJECT]","[LOCATION]","[TOPIC]").toString()).setPartition(-1799810326).setStartCursor(Cursor.newBuilder().build()).setEndCursor(Cursor.newBuilder().build()).build();ComputeMessageStatsResponseresponse=topicStatsServiceClient.computeMessageStats(request);}com.google.cloud.pubsublite.v1.stub
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-01 UTC.