컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
gcloud CLI를 사용하여 Pub/Sub에서 메시지 게시 및 수신
이 페이지에서는 Google Cloud CLI를 사용하여 Pub/Sub에서 다음 작업을 수행하는 방법을 보여줍니다.
- 주제 및 구독을 만듭니다.
- 주제에 메시지를 게시합니다.
- 구독에서 메시지를 수신합니다.
Google Cloud 콘솔에서 이 태스크에 대한 단계별 안내를 직접 수행하려면 둘러보기를 클릭합니다.
둘러보기
시작하기 전에
-
Google Cloud 계정에 로그인합니다. Google Cloud를 처음 사용하는 경우 계정을 만들고 Google 제품의 실제 성능을 평가해 보세요. 신규 고객에게는 워크로드를 실행, 테스트, 배포하는 데 사용할 수 있는 $300의 무료 크레딧이 제공됩니다.
-
Set up a Google Cloud console project.
Set up a project
Click to:
- Create or select a project.
-
Enable the Pub/Sub API for that project.
You can view and manage these resources at any time in the
Google Cloud console.
-
Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
Set up a Google Cloud console project.
Set up a project
Click to:
- Create or select a project.
-
Enable the Pub/Sub API for that project.
You can view and manage these resources at any time in the
Google Cloud console.
-
Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
주제 만들기
ID가 my-topic
인 주제를 만듭니다.
gcloud pubsub topics create my-topic
구독 만들기
ID가 my-sub
인 구독을 만들고 my-topic
에 연결합니다.
gcloud pubsub subscriptions create my-sub --topic=my-topic
메시지 게시
my-topic
에 메시지를 게시합니다.
gcloud pubsub topics publish my-topic --message="hello"
메시지 수신
my-sub
에서 메시지를 수신합니다.
gcloud pubsub subscriptions pull my-sub --auto-ack
gcloud CLI는 명령줄에 메시지를 인쇄합니다.
어땠나요?
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2024-09-27(UTC)
[{
"type": "thumb-down",
"id": "hardToUnderstand",
"label":"Hard to understand"
},{
"type": "thumb-down",
"id": "incorrectInformationOrSampleCode",
"label":"Incorrect information or sample code"
},{
"type": "thumb-down",
"id": "missingTheInformationSamplesINeed",
"label":"Missing the information/samples I need"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"번역 문제"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"기타"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"이해하기 쉬움"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"문제가 해결됨"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"기타"
}]
{"lastModified": "\ucd5c\uc885 \uc5c5\ub370\uc774\ud2b8: 2024-09-27(UTC)"}
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2024-09-27(UTC)"]]