Skip to content
Advertisement

Ways to implement Google Pub Sub

I found these 3 ways for implementing messaging with Google Pub Sub:

  1. with client libraries https://cloud.google.com/pubsub/docs/publisher

  2. with spring integration message channels and PubSubTemplate API https://dzone.com/articles/spring-boot-and-gcp-cloud-pubsub

  3. without message channels but with PubSubTemplate API https://medium.com/bb-tutorials-and-thoughts/gcp-how-to-subscribe-and-send-pubsub-messages-in-spring-boot-app-b27e2e8863e3

I want to understand the differences between them / when each is best to use and which would be useful for my case.

I have to implement a single Topic and a single Subscription to get the queue functionality. I think I’d rather not use Spring message channels if not needed , they seem to intermediate the communication between Pub Sub topic and the subscription and I don’t want that. I want things simple , so I think the option 3 would be best but I am also wondering about option 1.

Advertisement

Answer

Option 1, client libraries, is universal. You don’t need Spring to run it, you can use this library in Groovy or in Kotlin also.

Option 2, it’s deeply integrated to Spring. It’s quite invisible but if you have special thing to do, it’s tricky to override this implementation

Option 3, it’s a light spring integration. PubSubTemplate (the client in fact) is loaded automatically for you at startup, as any bean and you can use it easily in your code. It’s my preferred option when I use Spring.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement