Differentiate between spring cloud gcp pub sub and google cloud pub sub

1k Views Asked by At

If I want to send message to Google PubSub and consume message from it.Would you recommend using Spring cloud GCP library or just using Google Cloud Java API.

Can anyone differentiate between these two or what are features spring cloud gcp provide as compared to google cloud pubsub library.

2

There are 2 best solutions below

0
On

Cloud Pub/Sub API

  • Pub/Sub is a Google Cloud platform managed service and client libraries are developed and maintained by Google.
  • Using Google Cloud Pub/Sub with Client libraries is one of the standard and easiest ways to implement Cloud Pub/Sub and to use Pub/Sub with client libraries,You can follow this setup and tutorial for further information.
  • Here you won't require Spring integration, you can directly use the client library to publish messages and pull it from subscription.

Spring Cloud GCP

  • Spring has partnered with Google Cloud in order to allow users to interact with Pub/Sub from its side.

  • It uses the Google Cloud Java Client for Pub/Sub to interact with Google Cloud Pub/Sub.

  • Quoting from the documentation:

PubSubOperations is an abstraction that allows Spring users to use Google Cloud Pub/Sub without depending on any Google Cloud Pub/Sub API semantics. It provides the common set of operations needed to interact with Google Cloud Pub/Sub. PubSubTemplate is the default implementation of PubSubOperations and it uses the Google Cloud Java Client for Pub/Sub to interact with Google Cloud Pub/Sub.

If you want to use Pub/Sub with Java applications built with the Spring Framework you can use Spring cloud GCP or Otherwise, if you are interested in using only Pub/Sub or using it with some other product that doesn’t surround Spring Framework, the best option is to use any of the Client libraries that Google Cloud Platform offers.

2
On

The difference is whether you prefer to configure the objects programmatically (with client library) or through properties (with spring-cloud-gcp's PubSubTemplate). Spring Cloud GCP uses the underlying client library objects to talk to Cloud Pub/Sub, but it autoconfigures these objects with sensible defaults, allowing you to use properties to control specific behavior.