1

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 Kubernetes 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.

Kamila
  • 371
  • 5
  • 13

1 Answers1

0

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.

Shipra Sarkar
  • 1,385
  • 3
  • 10
  • Thank you for your reply. Do I understand correctly that Spring Cloud Stream is generally preferred way? When starting new application, it neither uses Spring Cloud Stream nor message channels, this is actually the moment when one of both needs to be picked, thus I was wondering if there are clear guidelines which one is better when – Kamila Dec 29 '22 at 12:10
  • If you want to develop a program with the primary responsibility of consuming messages and producing new messages, then Spring Cloud Stream is the ideal mechanism. If the events are just something you need to update the state of a larger application then consuming events with a listener is probably what you want to do. – Corneil du Plessis Jan 14 '23 at 16:25