Google PubSub 订阅者可以订阅多个订阅吗?
以下是典型的 GCP pubsub 模型:
我的问题:一个订阅者(应用程序或工作)是否可以订阅多个订阅?像这样:
我的意思是我们可以在订阅级别过滤某个订阅采用一种事件类型(A 或 B)。我知道如果我们有两个主题(主题 A 和 B)并创建两个订阅会更容易,但同样,它会归结为同一个问题,一个订阅者是否可以订阅多个订阅?< /strong>
或者我能想到的唯一替代方法是,在订阅者级别,我可以对事件类型 A 或 B 进行分类,但这需要发布者将属性传递到主题级别。
我拥有发布者的控制权,我只想做一个订阅者而不是多个订阅者。
Below is a typical GCP pubsub model:
My question: is it possible for one subscriber(application or job) to subscribe to multiple subscriptions? Like this:
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.
I have the control of publisher and I just wanna do one Subscriber instead of multiple subscribers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个应用程序可以订阅多个订阅,是的。您需要实例化订阅者客户端的多个实例,每个实例对应您想要接收消息的订阅。
如果您希望订阅者能够在不知道所有订阅名称的情况下接收消息,那么您可以使用 推送订阅并将端点设置为同一 URL 的不同订阅。然后,该 URL 后面的订阅者将接收来自不同订阅的消息。
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.