Class TopicCreateOptions

java.lang.Object
io.github.flink.gcp.connector.pubsub.sink.TopicCreateOptions
All Implemented Interfaces:
Serializable

@Public public final class TopicCreateOptions extends Object implements Serializable
Settings the sink applies when it creates a topic that does not exist.

Unlike the source's SubscriptionCreateOptions, supplying these options is not what authorises creation — CreateDisposition is, because a topic (unlike a subscription) can meaningfully be created with defaults. The options are purely additive: without them, CreateDisposition.CREATE_IF_NEEDED creates the topic with every field at its service default. Combining them with CreateDisposition.CREATE_NEVER is rejected by PubSubSinkBuilder.build(), since they would configure a topic the sink never creates.

One options object applies to every topic the sink creates. With dynamic destinations (a DestinationResolver) each missing topic is created with these same settings; there is no per-topic map, because unlike a subscription's topic binding, nothing in the settings ties them to one topic.

Options only affect creation. A topic that already exists is used exactly as it is configured, and these settings are neither applied to it nor compared against it.

Every knob 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 (a message retention of 10 minutes to 31 days, for example) are left to Pub/Sub, whose rejection already names the field and the limit. An all-unset object is allowed and equivalent to supplying no options at all.

See Also:
  • Method Details

    • builder

      public static TopicCreateOptions.Builder builder()
      Returns a builder. Every knob is optional.
    • getMessageRetention

      @Nullable public Duration getMessageRetention()
      Returns how long the topic retains published messages, or null for the Pub/Sub default (no topic-level retention).
    • getKmsKeyName

      @Nullable public String getKmsKeyName()
      Returns the Cloud KMS key the topic encrypts messages with, or null for Google-managed encryption.
    • getAllowedPersistenceRegions

      @Nullable public List<String> getAllowedPersistenceRegions()
      Returns the regions messages published to the topic may be persisted in, or null when the organization policy decides.
    • isEnforceInTransit

      public boolean isEnforceInTransit()
      Returns whether publishes from outside the allowed regions are rejected in transit.
    • 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