【GCP】Qwiklabs の「ベースライン: インフラストラクチャ」を勉強しています~Google Cloud Pub/Sub: Qwik Start – コマンドライン~

Google Cloud Pub/Sub: Qwik Start - コマンドライン GCP
Google Cloud Pub/Sub: Qwik Start - コマンドライン

Qwiklabs の「ベースライン: インフラストラクチャ」を進めていきたいと思います。

Google Cloud Pub/Sub: Qwik Start – コマンドライン

概要

Google Cloud Pub/Sub は、アプリケーションやサービスの間でイベントデータを交換するためのメッセージングサービスです。Cloud Pub/Sub の基礎を学びます。

コマンド

Pub/Sub トピック

gcloud pubsub topics create myTopic
gcloud pubsub topics create Test1
gcloud pubsub topics create Test2
gcloud pubsub topics list
gcloud pubsub topics delete Test1
gcloud pubsub topics delete Test2
gcloud pubsub topics list

Pub/Sub サブスクリプション

gcloud pubsub subscriptions create --topic myTopic mySubscription
gcloud pubsub subscriptions create --topic myTopic Test1
gcloud pubsub subscriptions create --topic myTopic Test2
gcloud pubsub topics list-subscriptions myTopic
gcloud pubsub subscriptions delete Test1
gcloud pubsub subscriptions delete Test2
gcloud pubsub topics list-subscriptions myTopic

Pub/Sub のパブリッシュと 1 つのメッセージの pull

gcloud pubsub topics publish myTopic --message "Hello"
gcloud pubsub topics publish myTopic --message "Publisher's name is XXXX"
gcloud pubsub topics publish myTopic --message "Publisher likes to eat meat"
gcloud pubsub topics publish myTopic --message "Publisher thinks Pub/Sub is awesome"

gcloud pubsub subscriptions pull mySubscription --auto-ack

Pub/Sub でサブスクリプションからすべてのメッセージを pull する

gcloud pubsub topics publish myTopic --message "Publisher is starting to get the hang of Pub/Sub"
gcloud pubsub topics publish myTopic --message "Publisher wonders if all messages will be pulled"
gcloud pubsub topics publish myTopic --message "Publisher will have to test to find out"

gcloud pubsub subscriptions pull mySubscription --auto-ack --limit=3

まとめ

Cloud Pub/Sub の基礎を学びました。
他のサービスと連携させて使えそうです。

https://www.papacoder.net/gcp-training-free-campaign/

コメント

タイトルとURLをコピーしました