2
votes

I found these 3 ways from 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

The problem is I don't understand exactly 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.

What is your advice? What are the pros/cons for each? Thanks!

1

1 Answers

0
votes

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.