Class PubSubSubscriberOptions

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

@Public public final class PubSubSubscriberOptions extends Object implements Serializable
Tuning options for the source's Pub/Sub subscribers and its reader: SDK flow control, the streaming-pull connection count and the acknowledgement-deadline extension settings, plus the source's own drain size, subscriber shutdown budget and first-checkpoint watchdog.

Set via PubSubSourceBuilder.subscriberOptions(PubSubSubscriberOptions); optional — every knob left unset keeps the SDK's (or the source's) default behavior, so defaults() is equivalent to not setting options at all.

SDK flow control limits what its subscriber holds while acknowledgement deadlines are still extended. That limit lapses after PubSubSubscriberOptions.Builder.maxAckExtensionPeriod(Duration) when nothing drains, so the source also enforces a reader-wide hard bound through PubSubSubscriberOptions.Builder.subscriberBufferMaxMessages(long) and PubSubSubscriberOptions.Builder.subscriberBufferMaxBytes(long). A separate per-split bound parks subscribers paused by watermark alignment through PubSubSubscriberOptions.Builder.pausedSplitBufferMaxMessages(long) and PubSubSubscriberOptions.Builder.pausedSplitBufferMaxBytes(long). The source still acknowledges emitted records only after checkpoint completion.

The subscriber shutdown mode is deliberately not a knob. It is fixed to NACK_IMMEDIATELY so that closing a reader releases messages at once; the SDK's WAIT_FOR_PROCESSING default would wait for acknowledgements that only arrive at checkpoint completion, which never happens during shutdown. Only PubSubSubscriberOptions.Builder.shutdownTimeout(Duration) is configurable.

Instances are immutable and serializable.

See Also:
  • Method Details

    • builder

      public static PubSubSubscriberOptions.Builder builder()
      Returns:
      a new builder
    • defaults

      public static PubSubSubscriberOptions defaults()
      Returns the default options: every knob left where PubSubSubscriberOptions.Builder initialises it, which is the SDK's own default wherever the source has no reason to pick one.

      The values themselves are on the reference/pubsub.md table, one row per setter, rather than enumerated here.

      Returns:
      the default options
    • getFlowControlMaxOutstandingElementCount

      @Nullable public Long getFlowControlMaxOutstandingElementCount()
      Returns the flow-control outstanding-message limit, or null for the SDK default.
    • getFlowControlMaxOutstandingRequestBytes

      @Nullable public Long getFlowControlMaxOutstandingRequestBytes()
      Returns the flow-control outstanding-byte limit, or null for the SDK default.
    • getSubscriberBufferMaxMessages

      public long getSubscriberBufferMaxMessages()
      Returns the reader-wide hard cap on messages retained in subscriber buffers.
    • getSubscriberBufferMaxBytes

      public long getSubscriberBufferMaxBytes()
      Returns the reader-wide hard cap on serialized bytes retained in subscriber buffers.
    • getPausedSplitBufferMaxMessages

      @Nullable public Long getPausedSplitBufferMaxMessages()
      Returns the message cap on a paused split's buffer, or null for twice the effective flow-control outstanding-message limit.
    • getPausedSplitBufferMaxBytes

      @Nullable public Long getPausedSplitBufferMaxBytes()
      Returns the byte cap on a paused split's buffer, or null for twice the effective flow-control outstanding-byte limit.
    • getParallelPullCount

      @Nullable public Integer getParallelPullCount()
      Returns the streaming-pull connection count, or null for the SDK default.
    • getMaxAckExtensionPeriod

      @Nullable public Duration getMaxAckExtensionPeriod()
      Returns the total acknowledgement-deadline extension budget, or null for the SDK default.
    • getMinDurationPerAckExtension

      @Nullable public Duration getMinDurationPerAckExtension()
      Returns the smallest single deadline extension, or null for the SDK default.
    • getMaxDurationPerAckExtension

      @Nullable public Duration getMaxDurationPerAckExtension()
      Returns the largest single deadline extension, or null for the SDK default.
    • getAwaitAckConfirmation

      @Nullable public Duration getAwaitAckConfirmation()
      Returns how long a completed checkpoint waits for its acknowledgements to be confirmed, or null when acknowledgement is fire-and-forget.
    • getShutdownTimeout

      public Duration getShutdownTimeout()
      Returns how long closing one subscriber waits for it to release its messages.
    • getMaxRecordsPerFetch

      public int getMaxRecordsPerFetch()
      Returns the maximum number of messages drained from one split per fetch.
    • getFirstCheckpointTimeout

      public Duration getFirstCheckpointTimeout()
      Returns how long the reader waits for its first checkpoint before failing the job, or Duration.ZERO when the watchdog is disabled.
    • 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