如何在一个带有Spring Cloud的Spring Boot应用程序中连接/配置两个pubsub gcp项目? [英] How to wire/configure two pubsub gcp projects in one spring boot application with spring cloud?

查看:211
本文介绍了如何在一个带有Spring Cloud的Spring Boot应用程序中连接/配置两个pubsub gcp项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我们正在GCP项目中开发一个Spring Boot应用程序,该应用程序连接到同一GCP项目中的PubSub终结点,而且还连接到另一个 GCP项目中的PubSub终结点.我想使用普通的Spring Cloud GCP PubSub组件,但是有了这些,我没有机会将第二个PubSub连接设置到第二个GCP项目.另外,如果我有一个服务帐户,则使用PubSubTemplate对象,除了服务帐户中的当前项目外,我不可能将目标定位到另一个项目中.是实现/扩展PubSubAdmin/PubSubTemplate的唯一方法,还是JPA数据库的解决方案,例如多连接和模板?

Currently, we're working on a spring boot application in a GCP project, which connects to a PubSub endpoint in the same GCP project, but also to a PubSub endpoint in another GCP project. I want to use plain spring cloud GCP PubSub components, but with those, I have no chance to set a second PubSub connection to a second GCP project. Also, if I would have one service account, with PubSubTemplate object I have no possibility to target a topic in another project than the current from the service account. Is the only way to implement/extend the PubSubAdmin/PubSubTemplate or is there also a solution like multiple connection and template for JPA databases?

亲切问候 斯文

推荐答案

考虑到另一个项目的正确权限,您可以使用完全限定的主题/订阅名称发布/订阅不同项目中的主题

Considering correct privileges for another project,you can publish/subscribe to topics in different projects with a fully qualified topic/subscription name

例如对于主题发布pubSubTemplate.publish("projects/other-project/topics/the-topic", "payload").

这应该与最新的spring-cloud-gcp版本一起提供.有关更多详细信息,请参见此问题.

This should be available with the latest spring-cloud-gcp version. Please see this issue for more details.

这篇关于如何在一个带有Spring Cloud的Spring Boot应用程序中连接/配置两个pubsub gcp项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆