What is best practice in Pubsub messaging using direct GCP cloud Pubsub or Spring Integration?


What is the benefit of using Spring integartion as sender and receiver for gcp pubsub message?
i was publishing the messages using service activator as described here:


Then i have found that GCP cloud library has also support for Publisher in java language as example here:

So i am confused because i see Publisher is more simpler and seems easy to manage retries in case of failure and it has stop to save resources.

Then what is the benefit of using spring Integration in this case?
We are not yet on production so is it worth to refactor it and use GCP pubsub direct?

Any best practice or explanation how to choose best library are welcome please.



Google Cloud Java Client libraries follow the same idiomatic structure. You can use Secret Manager, Compute or PubSub, you will create and handle the object in the same way. It’s google style.

Same things for Spring: use annotation and naming convention and the spring magic occurs! Because you follow the idiomatic structure of Spring.

What is better? If you want to stick absolutely to Spring idioms, use it. If not, use the style that you want, the easiest to understand for the other teams member and the newcomers.

(I love spring, but I prefer to use the Google Cloud client library style. I feel less locked and sticky to a strict structure)

Answered By – guillaume blaquiere

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published