Principle:Apache Flink Async Sink Framework
| Knowledge Sources | |
|---|---|
| Domains | Async_Sink, Table_API |
| Last Updated | 2026-02-09 00:00 GMT |
Overview
Description
The Async Sink Table Integration Framework provides the table-level integration layer that bridges the AsyncSinkBase runtime implementation with Flink's SQL and Table API. Located in the flink-connector-base module under the org.apache.flink.connector.base.table and org.apache.flink.connector.base.table.sink packages, this framework enables connector developers to expose asynchronous sinks as dynamic table sinks with minimal boilerplate.
The framework consists of four principal components:
- AsyncDynamicTableSinkFactory -- An abstract
@PublicEvolvingclass implementingDynamicTableSinkFactory. It automatically registers the fiveAsyncSinkConnectorOptionsas optional table options, providesaddAsyncOptionsToBuilder()to wire configuration properties into a builder, and includes the innerAsyncDynamicSinkContextclass to encapsulate catalog table metadata such as encoding format, physical data type, and partition keys. - AsyncSinkConnectorOptions -- A
@PublicEvolvingconstants class defining fiveConfigOptionentries that map toAsyncSinkBasetuning parameters:sink.batch.max-size,sink.requests.max-inflight,sink.requests.max-buffered,sink.flush-buffer.size, andsink.flush-buffer.timeout. - AsyncDynamicTableSink -- An abstract
@PublicEvolvingclass implementingDynamicTableSinkthat stores the five async sink parameters. It providesaddAsyncOptionsToSinkBuilder()to propagate these parameters into anAsyncSinkBaseBuilderat runtime, along with properequals/hashCodeimplementations. - AsyncDynamicTableSinkBuilder -- An abstract
@PublicEvolvingbuilder class parameterized by request entry type and a self-referential builder type. It provides fluent setter methods for all five async sink parameters and an abstractbuild()method that concrete implementations override to construct the final sink.
Theoretical Basis
This framework applies the Abstract Factory pattern at the table layer. AsyncDynamicTableSinkFactory serves as the abstract factory that Flink's FactoryUtil discovers through Java SPI. The factory creates AsyncDynamicTableSink instances, which in turn produce the underlying AsyncSinkBase operator at execution time. This two-stage creation (factory produces table sink, table sink produces runtime operator) cleanly separates SQL/Table API concerns from DataStream-level execution.
The Builder pattern is employed by AsyncDynamicTableSinkBuilder to handle the nullable, optional nature of the five configuration parameters. Each parameter can be independently set, and Optional.ofNullable chains ensure that only explicitly specified values are propagated to the underlying AsyncSinkBaseBuilder. This design allows connector-specific defaults to remain in effect for any parameter the user does not override.
The framework also implements a Layered Configuration principle: configuration flows from SQL DDL properties through AsyncSinkConnectorOptions into the factory, then through the builder into the runtime sink. Each layer validates and transforms values appropriate to its level of abstraction.
| Component | Role | Key Methods |
|---|---|---|
AsyncDynamicTableSinkFactory |
Abstract factory for table sink creation | optionalOptions(), addAsyncOptionsToBuilder()
|
AsyncSinkConnectorOptions |
Configuration option definitions | Five static ConfigOption constants
|
AsyncDynamicTableSink |
Table sink wrapper for async sinks | addAsyncOptionsToSinkBuilder()
|
AsyncDynamicTableSinkBuilder |
Fluent builder for table sinks | setMaxBatchSize(), setMaxInFlightRequests(), build()
|