[英]Spring and Google Cloud PubSub - subscribing to events
Following documentation , there are multiple ways to integrate Google Cloud PubSub events with Spring application:按照文档,有多种方法可以将 Google Cloud PubSub 事件与 Spring 应用程序集成:
Spring Cloud GCP has several modules for sending messages to Pub/Sub topics and receiving messages from Pub/Sub subscriptions using the Spring Framework. Spring Cloud GCP 有几个模块,用于使用 Spring 框架向 Pub/Sub 主题发送消息以及从 Pub/Sub 订阅接收消息。 You can use these modules independently or combine them for different use cases:您可以独立使用这些模块或将它们组合用于不同的用例:
- Spring Cloud GCP Pub/Sub Starter lets you send and receive messages using helper classes and call the Pub/Sub Java client library for more advanced scenarios. Spring Cloud GCP Pub/Sub Starter 让您可以使用帮助类发送和接收消息,并调用 Pub/Sub Java 客户端库以实现更高级的场景。
- Spring Integration Channel Adapters for Pub/Sub let you connect Spring Integration Message Channels with Pub/Sub. Spring Pub/Sub 集成通道适配器让您可以将 Spring 集成消息通道与 Pub/Sub 连接起来。
- Spring Cloud Stream Binder for Pub/Sub lets you use Pub/Sub as messaging middleware in Spring Cloud Stream applications. Spring Cloud Stream Pub/Sub 绑定器让您可以在 Spring Cloud Stream 应用程序中使用 Pub/Sub 作为消息传递中间件。
I don't have full understanding - what are those different use cases mentioned, and how to determine, which module is best for which use case?我没有完全理解 - 提到了哪些不同的用例,以及如何确定哪个模块最适合哪个用例?
Application (Dockerized Spring Boot app, deployed to Kube.netes in GCP) I am working on is rather simple, it is expected to act upon received PubSub event, it is not going to publish any events itself.应用程序(Dockerized Spring Boot app,部署到 GCP 中的 Kube.netes)我正在处理的是相当简单的,它应该根据收到的 PubSub 事件采取行动,它本身不会发布任何事件。
Spring Cloud GCP Pub/Sub Starter
module contains the java client classes for pub sub which will be used by your spring application to perform administrative and functional operations (ie. sending and receiving messages). Spring Cloud GCP Pub/Sub Starter
模块包含 pub sub 的 java 客户端类,您的 spring 应用程序将使用它来执行管理和功能操作(即发送和接收消息)。
Spring Integration Channel Adapters for Pub/Sub
module is utilized when your spring application uses Message Channels .当您的 spring 应用程序使用Message Channels时,将使用Spring Integration Channel Adapters for Pub/Sub
模块。 This module will help routing message between message channel and pub/sub using channel adapters .该模块将帮助使用通道适配器在消息通道和发布/订阅之间路由消息。
Spring Cloud Stream Binder for Pub/Sub
module is used in Spring Cloud Stream Applications in order to utilize cloud Pub/Sub API. Spring Cloud Stream Binder for Pub/Sub
模块的绑定器用于 Spring 云 Stream应用程序以利用云发布/订阅 API。
Since, your application requirements are basic you can easily go for Spring Cloud GCP Pub/Sub Starter module.因为,您的应用程序要求是基本的,您可以轻松地 go Spring Cloud GCP Pub/Sub Starter 模块。 For more information you can refer to this Google documentation .有关详细信息,您可以参考此 Google 文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.