Reputation: 1476
I'm learning PubSub APIs. I published few messages to the Topic and when I used API Explorer to do subscriber pull
Method: projects.subscriptions.pull
the data does not seem to match what I actually published:
what I published: "Message number 13
what API Explorer returns is: NTlkMjdhYzQtZTUyZi00M2Q3LTk0ZTItNTZhNTM1ZGRlODNk
(attach screenshot)
Oddly, when using actual API (Python Client Library) to do subs pull, things are fine:
subscriber = pubsub_v1.SubscriberClient()
subscription_path = subscriber.subscription_path(PROJECT_ID, SUBSCRIPTION)
messages = subscriber.pull(subscription_path, max_messages=10, timeout=10, return_immediately=True)
print(messages.received_messages[0])
ack_id: "QV5AEkw2AERJUytDCypYEU4EISE-MD5FU0RQBhYsXUZIUTcZCGhRDk9eIz81IChFEAtTE1FcdhNaEGszXHUHUQ0YdHhncGgOQFMAEFl-VVsJPGh-Y3QAVwUfen5pdWJTGgQARHv7z4Dzvb9LZhg9XBJLLD5-PTVF"
message
{ data: "Message number 13"
message_id: "176868380899521"
publish_time {
seconds: 1535000824
nanos: 625000000
}}
Upvotes: 2
Views: 67
Reputation: 1108
Pubsub returns your data base64 encoded. It's necessary to decode this in order to retrieve the published message in its original form.
Upvotes: 1