E - type of stream itempublic static final class KafkaSinks.Builder<E> extends Object
| Modifier and Type | Method and Description |
|---|---|
Sink<E> |
build()
Builds the Sink object that you pass to the
GeneralStage.writeTo(Sink) method. |
KafkaSinks.Builder<E> |
exactlyOnce(boolean enable)
Enables or disables the exactly-once behavior of the sink using
two-phase commit of state snapshots.
|
KafkaSinks.Builder<E> |
extractKeyFn(FunctionEx<? super E,?> extractKeyFn)
Sets the function to extract the key from the stream items.
|
KafkaSinks.Builder<E> |
extractValueFn(FunctionEx<? super E,?> extractValueFn)
Sets the function to extract the value from the stream items.
|
KafkaSinks.Builder<E> |
topic(String topic)
Sets the topic to write the messages to, if you write all messages
to a single topic.
|
KafkaSinks.Builder<E> |
toRecordFn(FunctionEx<? super E,? extends org.apache.kafka.clients.producer.ProducerRecord<?,?>> toRecordFn)
Sets the function to convert stream items into Kafka's
ProducerRecord. |
@Nonnull public KafkaSinks.Builder<E> topic(String topic)
toRecordFn(FunctionEx). If you call this method, you
can't call the toRecordFn() method.topic - the topic name@Nonnull public KafkaSinks.Builder<E> extractKeyFn(@Nonnull FunctionEx<? super E,?> extractKeyFn)
toRecordFn(FunctionEx).
The default is to use null key.
extractKeyFn - a function to extract the key from the stream item@Nonnull public KafkaSinks.Builder<E> extractValueFn(@Nonnull FunctionEx<? super E,?> extractValueFn)
toRecordFn(FunctionEx).
The default is to use the input item directly.
extractValueFn - a function to extract the value from the stream item@Nonnull public KafkaSinks.Builder<E> toRecordFn(@Nullable FunctionEx<? super E,? extends org.apache.kafka.clients.producer.ProducerRecord<?,?>> toRecordFn)
ProducerRecord. This method allows you to specify all aspects of
the record (different topic for each message, partition,
timestamp...). If you use this method, you can't use topic(String), extractKeyFn(FunctionEx) or extractValueFn(FunctionEx).toRecordFn - a function to convert stream items into Kafka's
ProducerRecord@Nonnull public KafkaSinks.Builder<E> exactlyOnce(boolean enable)
See KafkaSinks.kafka(Properties) for more information.
The default value is true.
enable - If true, sink's guarantee will match the job
guarantee. If false, sink's guarantee will be at-least-once
even if job's is exactly-once@Nonnull public Sink<E> build()
GeneralStage.writeTo(Sink) method.Copyright © 2024 Hazelcast, Inc.. All rights reserved.