public Subscription getSubscription ( String subscriptionId ) throws Exception { // [START pubsub_get_subscription] try ( SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient . create ( ) ) { ProjectSubscriptionName subscriptionName = ProjectSubscriptionName . of ( projectId , subscriptionId ) ; Subscription subscription = subscriptionAdminClient . getSubscription ( subscriptionName ) ; return subscription ; } // [END pubsub_get_subscription] }
Example of getting a subscription .