K- incoming record key type
V- incoming record value type
public interface Receiver<K,V>
|Modifier and Type||Method and Description|
Creates a reactive Kafka receiver with the specified configuration options.
Invokes the specified function on the Kafka
Starts a Kafka consumer that consumes records from the subscriptions or partition assignments configured for this receiver.
static <K,V> Receiver<K,V> create(ReceiverOptions<K,V> options)
options- Configuration options of this receiver. Changes made to the options after the receiver is created will not be used by the receiver. A subscription using group management or a manual assignment of topic partitions must be set on the options instance prior to creating this receiver.
Every record must be acknowledged using
ReceiverOffset.acknowledge() in order
to commit the offset corresponding to the record. Acknowledged records are committed
based on the configured commit interval and commit batch size in
Records may also be committed manually using
Fluxcontaining each batch of consumer records returned by
ConsumerConfig.MAX_POLL_RECORDS_CONFIGcan be configured on
ReceiverOptionsto control the maximum number of records in a batch. Each batch is returned as one Flux. All the records in a batch are acknowledged automatically when its Flux terminates. Acknowledged records are committed periodically based on the configured commit interval and commit batch size of this receiver's
Fluxof consumer records that are committed before the record is dispatched to provide atmost-once delivery semantics. The offset of each record dispatched on the returned Flux is committed synchronously to ensure that the record is not re-delivered if the application fails.
This mode is expensive since each method is committed individually and records are
not delivered until the commit operation succeeds. The cost of commits may be reduced by
ReceiverOptions.atmostOnceCommitAheadSize(). The maximum number of records that
may be lost on each partition if the consuming application crashes is
commitAheadSize + 1.
Consumerassociated with this Receiver. The function is scheduled when the returned
Monois subscribed to. The function is executed on the thread used for other consumer operations to ensure that
Consumeris never accessed concurrently from multiple threads.
Functions that are directly supported through the reactive
receiver.doOnConsumer(consumer -> consumer.partitionsFor(topic)) .doOnSuccess(partitions -> System.out.println("Partitions " + partitions));
commitshould not be invoked from
function. The methods supported by
function- A function that takes Kafka