Jie Zhang
Jie Zhang

Reputation: 305

Can Google PubSub Subscriber Subscribe to Multiple Subscriptions?

Below is a typical GCP pubsub model:

enter image description here

My question: is it possible for one subscriber(application or job) to subscribe to multiple subscriptions? Like this:

enter image description here

I mean we can filter at the subscription level that one subscription takes one event type (A or B). I know it will be easier if we have two topics (Topic A and B) and create two subscriptions, but again, it will boil down to the same question, is it possible for one subscriber to subscribe to multiple subscriptions?

Or the only alternative way I can imagine is that at the subscriber level, I can classify the event type, A or B, but that requires the publisher to pass the attribute to the topic level.

enter image description here

I have the control of publisher and I just wanna do one Subscriber instead of multiple subscribers.

Upvotes: 2

Views: 4015

Answers (1)

Kamal Aboul-Hosn
Kamal Aboul-Hosn

Reputation: 17206

An application can subscribe to multiple subscriptions, yes. You would need to instantiate multiple instances of the subscriber client, one for each subscription for which you want to receive messages.

If you want the subscriber to be able to receive messages without knowing the names of all of the subscriptions, then you could use push subscriptions and set the endpoint to different subscriptions to the same URL. Then, the subscriber behind that URL would receive messages from the different subscriptions.

Upvotes: 4

Related Questions