Implementation:Apache Flink AsyncSinkBaseBuilder Build
| Knowledge Sources | |
|---|---|
| Domains | Stream_Processing, Configuration |
| Last Updated | 2026-02-09 00:00 GMT |
Overview
Concrete tool for configuring async sink batching and flow control parameters via a builder pattern provided by the Apache Flink connector-base module.
Description
The AsyncSinkBaseBuilder is an abstract generic builder that concrete sinks extend. It provides fluent setter methods for all async sink parameters. The build() method is abstract and must be implemented by concrete builders to produce the final AsyncSinkBase instance. Parameter values are stored as nullable fields; concrete builders validate required parameters.
Usage
Extend this builder in your custom async sink implementation. Call setter methods to configure batching and flow control parameters.
Code Reference
Source Location
- Repository: Apache Flink
- File: flink-connectors/flink-connector-base/src/main/java/org/apache/flink/connector/base/sink/AsyncSinkBaseBuilder.java
- Lines: L33-141
Signature
@PublicEvolving
public abstract class AsyncSinkBaseBuilder<
InputT,
RequestEntryT extends Serializable,
ConcreteBuilderT extends AsyncSinkBaseBuilder<?, ?, ?>> {
public ConcreteBuilderT setMaxBatchSize(int maxBatchSize);
public ConcreteBuilderT setMaxInFlightRequests(int maxInFlightRequests);
public ConcreteBuilderT setMaxBufferedRequests(int maxBufferedRequests);
public ConcreteBuilderT setMaxBatchSizeInBytes(long maxBatchSizeInBytes);
public ConcreteBuilderT setMaxTimeInBufferMS(long maxTimeInBufferMS);
public ConcreteBuilderT setMaxRecordSizeInBytes(long maxRecordSizeInBytes);
public abstract AsyncSinkBase<InputT, RequestEntryT> build();
}
Import
import org.apache.flink.connector.base.sink.AsyncSinkBaseBuilder;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| maxBatchSize | int | No | Max records per batch |
| maxInFlightRequests | int | No | Max concurrent async requests |
| maxBufferedRequests | int | No | Max entries buffered before blocking |
| maxBatchSizeInBytes | long | No | Max batch payload bytes |
| maxTimeInBufferMS | long | No | Max buffer time before flush |
| maxRecordSizeInBytes | long | No | Max single record size |
Outputs
| Name | Type | Description |
|---|---|---|
| sink | AsyncSinkBase<InputT, RequestEntryT> | Configured async sink instance |
Usage Examples
Extending the Builder
public class MyAsyncSinkBuilder extends AsyncSinkBaseBuilder<MyInput, MyRequest, MyAsyncSinkBuilder> {
@Override
public AsyncSinkBase<MyInput, MyRequest> build() {
return new MyAsyncSink(
getMaxBatchSize(),
getMaxInFlightRequests(),
getMaxBufferedRequests(),
getMaxBatchSizeInBytes(),
getMaxTimeInBufferMS(),
getMaxRecordSizeInBytes()
);
}
}
// Usage
MyAsyncSink sink = new MyAsyncSinkBuilder()
.setMaxBatchSize(500)
.setMaxInFlightRequests(10)
.setMaxBufferedRequests(5000)
.setMaxBatchSizeInBytes(5 * 1024 * 1024)
.setMaxTimeInBufferMS(5000)
.build();