public ListSubscriptionsPagedResponse listSubscriptions ( ) throws Exception { // [START pubsub_list_subscriptions] try ( SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient . create ( ) ) { ListSubscriptionsRequest listSubscriptionsRequest = ListSubscriptionsRequest . newBuilder ( ) . setProject ( ProjectName . of ( projectId ) . toString ( ) ) . build ( ) ; ListSubscriptionsPagedResponse response = subscriptionAdminClient . listSubscriptions ( listSubscriptionsRequest ) ; Iterable < Subscription > subscriptions = response . iterateAll ( ) ; for ( Subscription subscription : subscriptions ) { // do something with the subscription } return response ; } // [END pubsub_list_subscriptions] }
Example of listing subscriptions .