@@ -66,12 +66,12 @@ messages to it
6666 from google.cloud import pubsub
6767
6868 publisher = pubsub.PublisherClient()
69- topic = ' projects/{project_id} /topics/{topic} ' .format(
69+ topic_name = ' projects/{project_id} /topics/{topic} ' .format(
7070 project_id = os.getenv(' GOOGLE_CLOUD_PROJECT' ),
7171 topic = ' MY_TOPIC_NAME' , # Set this to something appropriate.
7272 )
73- publisher.create_topic()
74- publisher.publish(topic , b ' My first message!' , spam = ' eggs' )
73+ publisher.create_topic(topic_name )
74+ publisher.publish(topic_name , b ' My first message!' , spam = ' eggs' )
7575
7676 To learn more, consult the `publishing documentation `_.
7777
@@ -90,15 +90,16 @@ the topic, and subscribe to that.
9090 from google.cloud import pubsub
9191
9292 subscriber = pubsub.SubscriberClient()
93- topic = ' projects/{project_id} /topics/{topic} ' .format(
93+ topic_name = ' projects/{project_id} /topics/{topic} ' .format(
9494 project_id = os.getenv(' GOOGLE_CLOUD_PROJECT' ),
9595 topic = ' MY_TOPIC_NAME' , # Set this to something appropriate.
9696 )
9797 subscription_name = ' projects/{project_id} /subscriptions/{sub} ' .format(
9898 project_id = os.getenv(' GOOGLE_CLOUD_PROJECT' ),
9999 sub = ' MY_SUBSCRIPTION_NAME' , # Set this to something appropriate.
100100 )
101- subscription = subscriber.create_subscription(topic, subscription)
101+ subscription = subscriber.create_subscription(
102+ name = subscription_name, topic = topic_name)
102103
103104 The subscription is opened asychronously, and messages are processed by
104105use of a callback.
0 commit comments