{"id":15805002,"url":"https://github.com/ddobrin/cloud-pubsub-message-propagation","last_synced_at":"2025-03-31T22:04:35.724Z","repository":{"id":185136216,"uuid":"673061450","full_name":"ddobrin/cloud-pubsub-message-propagation","owner":"ddobrin","description":"Propagate messages between Cloud Pub/Sub topics with EventArc and Cloud Functions","archived":false,"fork":false,"pushed_at":"2023-08-01T16:22:23.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-06T02:03:22.869Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ddobrin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-31T19:29:11.000Z","updated_at":"2023-08-02T12:29:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"86830377-b9dd-4ba2-9094-cf31ba503102","html_url":"https://github.com/ddobrin/cloud-pubsub-message-propagation","commit_stats":null,"previous_names":["ddobrin/cloud-pubsub-message-propagation"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddobrin%2Fcloud-pubsub-message-propagation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddobrin%2Fcloud-pubsub-message-propagation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddobrin%2Fcloud-pubsub-message-propagation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddobrin%2Fcloud-pubsub-message-propagation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ddobrin","download_url":"https://codeload.github.com/ddobrin/cloud-pubsub-message-propagation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246547388,"owners_count":20794970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-05T02:02:51.262Z","updated_at":"2025-03-31T22:04:35.688Z","avatar_url":"https://github.com/ddobrin.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Publish messages from one Cloud Pub/Sub topic to another using EventArc and Cloud Functions v2\n\nCreate the upstream topic\n```shell\ngcloud pubsub topics create upstream\n```\n\nCreate the downstream topic\n```shell\ngcloud pubsub topics create downstream\n```\n\nBuild the code locally, for testing:\n```shell\n./mvnw package\n```\nDeploy the code, which creates the EventArc trigger automatically\n```shell\nexport PROJECT_ID=your-project\n\ngcloud iam service-accounts create cloud-function-pub-sub \\\n    --description=\"pub sub service account\" \\\n    --display-name=\"cloud-function-pub-sub\"\n\ngcloud projects add-iam-policy-binding $PROJECT_ID \\\n--member=--member=serviceAccount:cloud-function-pub-sub@$PROJECT_ID.iam.gserviceaccount.com \\\n--role=roles/pubsub.editor\n\ngcloud functions deploy upstream-downstream --gen2 --source=. --entry-point=functions.SubscribePublishToFromTopic --runtime java17   --ingress-settings internal-and-gclb    --service-account=\"\" --allow-unauthenticated --trigger-topic=upstream --region=us-central1\n```\n\nDeployment output\n```shell\n  ✓ [Build] Logs are available at [https://console.cloud.google.com/cloud-build/builds;region=us-central1/f214d9b7-d299-4a44-acc0-0b316aac8344?project=399726347076]                               \n    [Service]                                                                                                                                                                                      \n  . [Trigger]                                                                                                                                                                                      \n  . [ArtifactRegistry]                                                                                                                                                                             \n  . [Healthcheck]                                                                                                                                                                                  \n  . [Triggercheck]                                                                                                                                                                                 \nCompleted with warnings:                                                                                                                                                                           \n  [INFO] A new revision will be deployed serving with 100% traffic.\nYou can view your function in the Cloud Console here: https://console.cloud.google.com/functions/details/us-central1/upstream-downstream?project=test-project\n\nbuildConfig:\n  build: projects/399726347076/locations/us-central1/builds/f214d9b7-d299-4a44-acc0-0b316aac8344\n  entryPoint: functions.SubscribePublishToFromTopic\n  runtime: java17\n  source:\n    storageSource:\n      bucket: gcf-v2-sources-399726347076-us-central1\n      generation: '1690826283904793'\n      object: upstream-downstream/function-source.zip\n  sourceProvenance:\n    resolvedStorageSource:\n      bucket: gcf-v2-sources-399726347076-us-central1\n      generation: '1690826283904793'\n      object: upstream-downstream/function-source.zip\nenvironment: GEN_2\neventTrigger:\n  eventType: google.cloud.pubsub.topic.v1.messagePublished\n  pubsubTopic: projects/test-project/topics/upstream\n  retryPolicy: RETRY_POLICY_DO_NOT_RETRY\n  serviceAccountEmail: 399726347076-compute@developer.gserviceaccount.com\n  trigger: projects/test-project/locations/us-central1/triggers/upstream-downstream-384315\n  triggerRegion: us-central1\nlabels:\n  deployment-tool: cli-gcloud\nname: projects/test-project/locations/us-central1/functions/upstream-downstream\nserviceConfig:\n  allTrafficOnLatestRevision: true\n  availableCpu: '0.1666'\n  availableMemory: 256M\n  ingressSettings: ALLOW_INTERNAL_AND_GCLB\n  maxInstanceCount: 100\n  maxInstanceRequestConcurrency: 1\n  revision: upstream-downstream-00003-jal\n  service: projects/test-project/locations/us-central1/services/upstream-downstream\n  serviceAccountEmail: 399726347076-compute@developer.gserviceaccount.com\n  timeoutSeconds: 60\n  uri: https://upstream-downstream-ndn7ymldhq-uc.a.run.app\nstate: ACTIVE\nupdateTime: '2023-07-31T17:59:29.409772021Z'\nurl: https://us-central1-test-project.cloudfunctions.net/upstream-downstream\n\n```\n\nCreate a downstream topic subscription\n```shell\ngcloud pubsub subscriptions create downstream-sub --topic=downstream\n```\n\nSend messages to the upstream topic\n```shell\ngcloud pubsub topics publish upstream --message \"upstream-downstream\"\n```\n\nSubscribe to the downstream topic\n```shell\n gcloud pubsub subscriptions create downstream-sub --topic=downstream\n\n gcloud pubsub subscriptions pull downstream-sub --auto-ack\n```\n\nObserve the message\n```shell\n┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬──────────────────┬──────────────┬────────────┬──────────────────┬────────────┐\n│                                                                                                                                                  DATA                                                                                                                                                  │    MESSAGE_ID    │ ORDERING_KEY │ ATTRIBUTES │ DELIVERY_ATTEMPT │ ACK_STATUS │\n├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────────────────┼──────────────┼────────────┼──────────────────┼────────────┤\n│ {\"message\":{\"data\":\"dGVzdDI=\",\"messageId\":\"8755078934865762\",\"message_id\":\"8755078934865762\",\"publishTime\":\"2023-07-31T16:52:15.298Z\",\"publish_time\":\"2023-07-31T16:52:15.298Z\"},\"subscription\":\"projects/test-project/subscriptions/eventarc-us-central1-upstream-downstream-384315-sub-646\"} │ 8752093729087847 │              │            │                  │ SUCCESS    │\n└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────────────────┴──────────────┴────────────┴──────────────────┴────────────┘\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddobrin%2Fcloud-pubsub-message-propagation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fddobrin%2Fcloud-pubsub-message-propagation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddobrin%2Fcloud-pubsub-message-propagation/lists"}