פרסום וקבלת הודעות ב-Pub/Sub באמצעות המסוף Cloud de Confiance
בדף הזה מוסבר איך לבצע משימות בסיסיות ב-Pub/Sub באמצעות מסוףCloud de Confiance .
לפני שמתחילים
-
In the Cloud de Confiance console, on the project selector page, select or create a Cloud de Confiance project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Cloud de Confiance project.
Enable the Pub/Sub API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.-
Make sure that you have the following role or roles on the project: Pub/Sub Admin
Check for the roles
-
In the Cloud de Confiance console, go to the IAM page.
Go to IAM - Select the project.
-
In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
- For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
Grant the roles
-
In the Cloud de Confiance console, go to the IAM page.
Go to IAM - Select the project.
- Click Grant access.
-
In the New principals field, enter your user identifier. This is typically the identifier for a user in a workforce identity pool. For details, see Represent workforce pool users in IAM policies, or contact your administrator.
- Click Select a role, then search for the role.
- To grant additional roles, click Add another role and add each additional role.
- Click Save.
-
יצירת נושא
נכנסים לדף Pub/Sub במסוף Cloud de Confiance .
בדף נושאים, לוחצים על
יצירת נושא .בחלון שנפתח, מזינים
MyTopicבשדה Topic ID.משאירים את ערכי ברירת המחדל לאפשרויות שנותרו ולוחצים על יצירה.
מוצגת הודעת ההצלחה:
A new topic and a new subscription have been successfully created.הרגע יצרת נושא בשם
MyTopicומינוי ברירת מחדל משויךMyTopic-sub.
הוספת מינוי שני
כדי להוסיף מינוי שני לנושא שיצרתם, מבצעים את השלבים הבאים:
נכנסים לדף Pub/Sub subscriptions במסוף Cloud de Confiance .
בדף מינויים, לוחצים על יצירת מינוי.
מזינים
MySubבשדהSubscription ID (מזהה המינוי).בקטע Select a Cloud Pub/Sub topic, בוחרים את נושא
MyTopicמהתפריט הנפתח.משאירים את ערכי ברירת המחדל בשאר האפשרויות.
לוחצים על
יצירה .מוצגת הודעת ההצלחה:
Subscription successfully added.המינוי
MySubמצורף עכשיו לנושאMyTopic. Pub/Sub מעביר את כל ההודעות שנשלחות אלMyTopicלמינוייםMySubו-MyTopic-sub.
פרסום הודעה בנושא
נכנסים לדף Pub/Sub topics במסוף Cloud de Confiance .
לוחצים על הנושא
MyTopic.לוחצים על הדף
נושאים ואז עלMyTopic.בדף
MyTopic, לוחצים על הכרטיסייההודעות .לוחצים על
פרסום ההודעה .בחלון
גוף ההודעה , כותביםHello World.לוחצים על
פרסום . אם הפרסום הצליח, תופיע הודעה בתחתית הדף: 'ההודעה פורסמה'.
שליפת ההודעות מהמינוי
נכנסים לדף Pub/Sub subscriptions במסוף Cloud de Confiance .
בכרטיסייה Messages (הודעות), לוחצים על Pull (משיכה).
ההודעה שפרסמתם אמורה להופיע. ההודעה כוללת את הנתונים Hello World ואת השעה שבה ההודעה פורסמה.
כשמשתמשים במסוף Cloud de Confiance , שליפה בודדת של נתונים עם נפח הודעות נמוך יכולה להחזיר אפס הודעות. אם לא רואים הודעות, לוחצים על Pull כמה פעמים כדי לשלוח כמה בקשות pull. זו לא בעיה בספריות הלקוח של Pub/Sub.
הסרת המשאבים
כדי לא לצבור חיובים לחשבון Cloud de Confiance על המשאבים שבהם השתמשתם בדף הזה, פועלים לפי השלבים הבאים:
אם אתם לא צריכים יותר את הנושא והמינוי שיצרתם, אתם יכולים למחוק אותם.
כדי למחוק את הנושא והמינוי, מבצעים את השלבים הבאים:
עוברים לדף
נושאים .מסמנים את התיבה לצד
MyTopicולוחצים עלמחיקה .מבצעים את השלבים בחלון האישור כדי למחוק את הנושא באופן סופי.
אפשר גם למחוק את הפרויקט שיצרתם.
המאמרים הבאים
מידע נוסף על המושגים של Pub/Sub שמוסברים בדף הזה
קוראים את היסודות של שירות Pub/Sub.
אפשר לעיין בדוגמה מקצה לקצה של מערכת Pub/Sub.
אפשר לנסות מדריך למתחילים אחר של Pub/Sub שמשתמש בספריות לקוח או ב-Google Cloud CLI.