wordpress.com · web view2020. 5. 5. · -->sudo pip install --upgrade...
TRANSCRIPT
Enabling the Pub/Sub API
Creating topics and subscriptions using the Web Console
ms4446@cloudshell:~ (spikey-ps-277716)$ export PS1="\[\e[34m\]\w\[\e[m\]>\n-->"
-->gcloud pubsub subscriptions pull --auto-ack sale_day_offers_sub
-->gcloud pubsub subscriptions pull --auto-ack sale_day_offers_sub --limit 10
Use Pub/Sub using gcloud on the command line
-->gcloud pubsub topics create spikey_bugs
cloud pubsub subscriptions create --topic spikey_bugs --ack-deadline=60 spikey_bugs_dev_sub
-->gcloud pubsub subscriptions create --topic spikey_bugs --ack-deadline=60 spikey_bugs_reports_sub
-->gcloud pubsub topics publish spikey_bugs --message "Tester 1: Problem editing number of items in the cart."messageIds:- '1199570934110741'
-->gcloud pubsub subscriptions pull --auto-ack spikey_bugs_dev_sub
-->gcloud pubsub subscriptions pull --auto-ack spikey_bugs_reports_sub
-->gcloud pubsub topics publish spikey_bugs --message "Tester 2: Citibank - Wrong URL of the payment gateway."
messageIds:- '1199579153053147'
-->gcloud pubsub subscriptions pull spikey_bugs_dev_sub
-->gcloud pubsub subscriptions pull spikey_bugs_dev_sub
->gcloud pubsub subscriptions ack spikey_bugs_dev_sub --ack-ids=ISE-MD5FU0RQBhYsXUZIUTcZCGhRDk9eIz81IChFFwMIFAV8fXFeW3VbXhoHUQ0Zcnxmd2PE1cKFAErVVsRDXptXFcnUAwQe3hmfGtfEAEHRlJ6WHPm-rvA4qWnYxclSv2e1axvM-uFoI1MZho9XxJLLD5-MzZFQV5AEkw4A0RJUytDCypYEU4E
Acked the messages with the following ackIds: [ISE-MD5FU0RQBhYsXUZIUTcZCGhRDk9eIz81IChFFwMIFAV8fXFeW3VbXhoHUQ0Zcnxmd2PE1cKFAErVVsRDXptXFcnUAwQe3hmfGtfEAEHRlJ6WHPm-rvA4qWnYxclSv2e1axvM-uFoI1MZho9XxJLLD5-MzZFQV5AEkw4A0RJUytDCypYEU4E]{}
-->gcloud pubsub subscriptions pull spikey_bugs_dev_subListed 0 items.
-->gcloud pubsub topics list---name: projects/spikey-ps-277716/topics/sale_day_offers---name: projects/spikey-ps-277716/topics/spikey_bugs
->gcloud pubsub subscriptions list
-->gcloud pubsub topics list-subscriptions spikey_bugs
-->gcloud pubsub subscriptions delete spikey_bugs_dev_sub
Deleted subscription [projects/spikey-ps-277716/subscriptions/spikey_bugs_dev_sub].
-->gcloud pubsub topics list
name: projects/spikey-ps-277716/topics/sale_day_offers
name: projects/spikey-ps-277716/topics/spikey_bugs
-->gcloud pubsub topics delete spikey_bugs
Deleted topic [projects/spikey-ps-277716/topics/spikey_bugs].
Create snapshots and seek to snapshots on Pub/Sub subscriptions
-->gcloud beta pubsub topics create spikey_customer_service
Created topic [projects/spikey-ps-277716/topics/spikey_customer_service].
-->gcloud beta pubsub subscriptions create spikey_customer_service_sub1 --topic=spikey_customer_service --ack--deadline=10
gcloud beta pubsub subscriptions create spikey_customer_service_sub1 --topic=spikey_customer_service --ack-deadline=10
Created subscription [projects/spikey-ps-277716/subscriptions/spikey_customer_service_sub1].
-->gcloud beta pubsub topics publish spikey_customer_service --message "Issue 1: User can't login from a particular location"
messageIds:- '1199646388296894'
-->gcloud beta pubsub subscriptions pull --auto-ack spikey_customer_service_sub1
-->gcloud beta pubsub topics publish spikey_customer_service --message 'Issue 2: Change of delivery address'
messageIds:- '1199655109733827'
Create snapshots
-->gcloud beta pubsub snapshots create customer_service_snapshot --subscription=spikey_customer_service_sub1
Created snapshot [projects/spikey-ps-277716/snapshots/customer_service_snapshot].
-->gcloud beta pubsub topics publish spikey_customer_service --message 'Issue 3: Edit the size of the item ordered.'
messageIds:- '1199663717750192'
-->gcloud beta pubsub topics publish spikey_customer_service --message 'Issue 4: Edit requesting an out-of-stock item.'messageIds:- '1199663766854173'
-->gcloud beta pubsub subscriptions seek spikey_customer_service_sub1 --snapshot=customer_service_snapshot
snapshotId: projects/spikey-ps-277716/snapshots/customer_service_snapshotsubscriptionId: projects/spikey-ps-277716/subscriptions/spikey_customer_service_sub1
-->gcloud beta pubsub subscriptions create spikey_customer_service_sub2 --topic=spikey_customer_service --ack-deadline=10
From UI apply Snapshot to Sub2
-->gcloud beta pubsub snapshots delete customer_service_snapshot
Deleted snapshot [projects/spikey-ps-277716/snapshots/customer_service_snapshot].
Retain message and seek to timestamp
-->gcloud pubsub topics list
name: projects/spikey-ps-277716/topics/spikey_customer_service
-->gcloud pubsub subscriptions list
-->gcloud beta pubsub subscriptions update spikey_customer_service_sub1 --retain-acked-messages
Updated subscription [projects/spikey-ps-277716/subscriptions/spikey_customer_service_sub1].
-->gcloud beta pubsub subscriptions pull --auto-ack spikey_customer_service_sub1
Listed 0 items.
-->gcloud beta pubsub topics publish spikey_customer_service --message 'Issue 5: Mobile App is stuck at the screen!'
messageIds:- '1200394163899973'
-->gcloud beta pubsub subscriptions pull --auto-ack spikey_customer_service_sub1Listed 0 items.
Using Pub/Sub with a push subscription
Prerequisite
1. On the Cloud Functions homepage, highlight the Cloud Function you want to add all access to.
2. Click "Show Info Panel" on the top right.3. Click "Add Members" and type "allUsers" then select "Cloud Function Invokers"
under "Cloud Function" in the Role box.4. Click "Save"
Using a Cloud Function as a Webhook Endpoint
Creating a Service Account to Use Client Libraries
All Scripts located at:
https://app.pluralsight.com/library/courses/google-cloud-platform-pubsub-architecting-stream-processing-solutions/exercise-files
-->ls -n spikey-ps-277716-7bf6dfb3c886.json
-rw-r--r-- 1 1000 1000 2335 May 21 14:28 spikey-ps-277716-7bf6dfb3c886.json
-->export GOOGLE_APPLICATION_CREDENTIAL=~/spikey-ps.json
-->sudo pip install --upgrade google-cloud-pubsub-->gcloud pubsub topics create spikey_bug_report
-->gcloud pubsub subscriptions create spikey_bug_report_sub --topic spikey_bug_report
Asynchronous Publishing using callbacks
Publishes and parsing messages with custom attributes
Using subscribers with flow control
Publishing messages in batches
\