简体   繁体   中英

Spring and Google Cloud PubSub - subscribing to events

Following documentation , there are multiple ways to integrate Google Cloud PubSub events with Spring application:

Spring Cloud GCP has several modules for sending messages to Pub/Sub topics and receiving messages from Pub/Sub subscriptions using the Spring Framework. 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 Integration Channel Adapters for Pub/Sub let you connect Spring Integration Message Channels with Pub/Sub.
  • Spring Cloud Stream Binder for Pub/Sub lets you use Pub/Sub as messaging middleware in Spring Cloud Stream applications.

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.

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 Integration Channel Adapters for Pub/Sub module is utilized when your spring application uses Message Channels . 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.

Since, your application requirements are basic you can easily go for Spring Cloud GCP Pub/Sub Starter module. For more information you can refer to this Google documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM