Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I forward a GCP Pubsub subscription's messages to another topic?

I would like to be able to forward a Google Cloud Platform (GCP) Pubsub subscription's messages to another GCP topic, which is possibly in another GCP Project.

  1. Is this possible via Push endpoint URL (What would the url of the destination topic be?)
  2. Some other easy configuration via API?
  3. (workaround) Alternatively, how would you provide this functionality?
like image 490
successhawk Avatar asked Oct 25 '25 14:10

successhawk


2 Answers

There is a Dataflow template called Cloud_PubSub_to_Cloud_PubSub that read messages from a Pubsub subscription (inputSubscription) and publish the messages to a Pubsub topic (outputTopic).

Be sure that the service account used to launch the Dataflow job has the right permissions (roles/pubsub.subscriber in the project where inputSubscription is defined or directly on inputSubscription, and roles/pubsub.publisher in the project containing outputTopic or directly on outputTopic).

You can take a look at the code on GitHub if you are familiar with Java.

like image 84
norbjd Avatar answered Oct 27 '25 08:10

norbjd


The only way to do this would be to publish the messages to the other topic in a subscriber you write when it receives the messages. There is no automated way to forward messages from one topic to another.

like image 27
Kamal Aboul-Hosn Avatar answered Oct 27 '25 09:10

Kamal Aboul-Hosn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!