Class SubscriptionCreateOptions

java.lang.Object
io.github.flink.gcp.connector.pubsub.source.SubscriptionCreateOptions
All Implemented Interfaces:
Serializable

@Public public final class SubscriptionCreateOptions extends Object implements Serializable
Settings the source applies when it creates a subscription that does not exist.

Supplying these options for a subscription is what authorises creating it. There is no separate disposition enum, because there is no meaningful "create with defaults": a subscription without a topic is not a subscription, and only the user knows which topic to bind. A subscription passed to PubSubSourceBuilder.subscription(SubscriptionDestination) without options must therefore already exist, and the source fails at startup if it does not.

Options are per subscription, and the topic binding is why. One options object shared by several subscriptions would bind them all to the same topic, and Pub/Sub delivers a complete copy of the stream to every subscription of a topic — so the source would emit each message once per subscription, with nothing anywhere reporting an error.

Options only affect creation. A subscription that already exists is used exactly as it is configured, and these settings are neither applied to it nor compared against it (except for the two the source cannot work around, which the startup check rejects: ordering under OrderingMode.PER_KEY, and exactly-once delivery).

Every knob but the topic is optional and unset means absent, leaving Pub/Sub's own default. Values are validated here only where the failure would otherwise be silent or obscure; documented service ranges (an acknowledgement deadline of 10-600 seconds, for example) are left to Pub/Sub, whose rejection already names the field and the limit.

See Also:
  • Method Details

    • builder

      public static SubscriptionCreateOptions.Builder builder()
      Returns a builder. The topic is required; everything else is optional.
    • getTopic

      public TopicDestination getTopic()
      Returns the topic the subscription is created against.
    • getAckDeadline

      @Nullable public Duration getAckDeadline()
      Returns the acknowledgement deadline, or null for the Pub/Sub default (10 s).
    • isEnableMessageOrdering

      public boolean isEnableMessageOrdering()
      Returns whether the subscription is created with ordering-key ordering enabled.
    • getMessageRetention

      @Nullable public Duration getMessageRetention()
      Returns how long messages are retained, or null for the Pub/Sub default (7 days).
    • isRetainAckedMessages

      public boolean isRetainAckedMessages()
      Returns whether acknowledged messages are retained for replay.
    • getExpirationTtl

      @Nullable public Duration getExpirationTtl()
      Returns how long the subscription may sit inactive before Pub/Sub deletes it, or null when the default (31 days) applies or when expiration is disabled — see isNeverExpire().
    • isNeverExpire

      public boolean isNeverExpire()
      Returns whether the subscription is created never to expire.
    • getDeadLetterTopic

      @Nullable public TopicDestination getDeadLetterTopic()
      Returns the topic undeliverable messages are forwarded to, or null when no dead-letter policy is configured.
    • getDeadLetterMaxDeliveryAttempts

      public int getDeadLetterMaxDeliveryAttempts()
      Returns how many delivery attempts a message gets before it is dead-lettered, or 0 when no dead-letter policy is configured.
    • getFilter

      @Nullable public String getFilter()
      Returns the subscription filter expression, or null when unfiltered.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object