Search code examples
spring-cloudgoogle-cloud-pubsubspring-cloud-gcp

Exactly once delivery semantics with Spring Cloud GCP


I have a project built with Spring Cloud GCP, which makes use of a subscription that is configured with Exactly once delivery enabled on GCP Pub/Sub subscription settings, and with Ack deadline set to 5 minutes (also in the GCP console).

Using Spring, I also have access to configure subscriber settings using configuration options (for example: spring.cloud.gcp.pubsub.subscriber.max-ack-extension-period=1800).

My question is twofold:

  • Which of these configurations (GCP console vs Spring configuration parameters) take effect in case of conflict?
  • Can I actually have exactly-once delivery semantics with Spring Cloud GCP (given that the feature is marked as having limited support in the docs: https://cloud.google.com/pubsub/docs/exactly-once-delivery)?

Solution

  • You can set the default ack timeout in your PubSub subscription and you can extend it (only for pull subscription) in your code, the max timeout being 10 minutes in any case.

    There is no conflict: there is a default configuration, and a programmatic extension in case of congestion for example


    The exactly-once delivery is also compliant with Spring Cloud GCP if you use the latest version, which use the latest Java client libraries. Spring Cloud GCP is only a wrapper that reuse the Spring programming framework but the underlying implementation still use the standard JAVA client libraries.