Class TopicCreateOptions.Builder

java.lang.Object
io.github.flink.gcp.connector.pubsub.sink.TopicCreateOptions.Builder
Enclosing class:
TopicCreateOptions

@Public public static final class TopicCreateOptions.Builder extends Object
Builder for TopicCreateOptions.
  • Method Details

    • messageRetention

      public TopicCreateOptions.Builder messageRetention(Duration messageRetention)
      Sets how long the topic retains published messages, whether or not they were acknowledged. Defaults to the Pub/Sub default: no topic-level retention, so a message is kept only as long as some subscription's own retention covers it. Topic retention is what lets a subscription created later — or a backwards seek — reach messages published before it existed or already acknowledged.
      Parameters:
      messageRetention - the retention duration
      Returns:
      this builder
    • kmsKeyName

      public TopicCreateOptions.Builder kmsKeyName(String kmsKeyName)
      Encrypts messages published to the topic with the given Cloud KMS key (customer-managed encryption) instead of Google-managed encryption. The key must already exist, and the Pub/Sub service account needs cloudkms.cryptoKeyEncrypterDecrypter on it — without that grant, publishes to the created topic fail.
      Parameters:
      kmsKeyName - the full key resource name, projects/P/locations/L/keyRings/R/cryptoKeys/K
      Returns:
      this builder
    • allowedPersistenceRegions

      public TopicCreateOptions.Builder allowedPersistenceRegions(List<String> allowedPersistenceRegions)
      Restricts which regions messages published to the topic may be persisted in (the topic's message storage policy). Defaults to whatever the project's organization policy allows.
      Parameters:
      allowedPersistenceRegions - the allowed Cloud regions, for example ["europe-west1", "europe-west4"]
      Returns:
      this builder
    • enforceInTransit

      public TopicCreateOptions.Builder enforceInTransit(boolean enforceInTransit)
      Rejects publishes travelling through regions outside the allowed persistence regions, instead of only restricting where messages are stored. Requires allowedPersistenceRegions(List), which build() enforces.
      Parameters:
      enforceInTransit - whether to enforce the storage policy in transit
      Returns:
      this builder
    • build

      public TopicCreateOptions build()
      Builds the options.
      Returns:
      the options