Class IncomingKafkaRecordBatch<K,T>
- java.lang.Object
-
- io.smallrye.reactive.messaging.kafka.IncomingKafkaRecordBatch<K,T>
-
- All Implemented Interfaces:
KafkaRecordBatch<K,T>
,Iterable<KafkaRecord<K,T>>
,Message<List<T>>
public class IncomingKafkaRecordBatch<K,T> extends Object implements KafkaRecordBatch<K,T>
-
-
Constructor Summary
Constructors Constructor Description IncomingKafkaRecordBatch(org.apache.kafka.clients.consumer.ConsumerRecords<K,T> records, KafkaCommitHandler commitHandler, KafkaFailureHandler onNack, boolean cloudEventEnabled, boolean tracingEnabled)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletionStage<Void>
ack()
Acknowledge this message.Supplier<CompletionStage<Void>>
getAck()
Map<org.apache.kafka.common.TopicPartition,KafkaRecord<K,T>>
getLatestOffsetRecords()
Metadata
getMetadata()
Function<Throwable,CompletionStage<Void>>
getNack()
List<T>
getPayload()
List<KafkaRecord<K,T>>
getRecords()
Iterator<KafkaRecord<K,T>>
iterator()
CompletionStage<Void>
nack(Throwable reason, Metadata metadata)
Acknowledge negatively this message.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface org.eclipse.microprofile.reactive.messaging.Message
addMetadata, getMetadata, nack, unwrap, withAck, withMetadata, withMetadata, withNack, withPayload
-
-
-
-
Constructor Detail
-
IncomingKafkaRecordBatch
public IncomingKafkaRecordBatch(org.apache.kafka.clients.consumer.ConsumerRecords<K,T> records, KafkaCommitHandler commitHandler, KafkaFailureHandler onNack, boolean cloudEventEnabled, boolean tracingEnabled)
-
-
Method Detail
-
getPayload
public List<T> getPayload()
- Specified by:
getPayload
in interfaceMessage<K>
- Returns:
- The payload for this message.
-
getRecords
public List<KafkaRecord<K,T>> getRecords()
- Specified by:
getRecords
in interfaceKafkaRecordBatch<K,T>
- Returns:
- list of records contained in this message batch
-
iterator
public Iterator<KafkaRecord<K,T>> iterator()
-
getLatestOffsetRecords
public Map<org.apache.kafka.common.TopicPartition,KafkaRecord<K,T>> getLatestOffsetRecords()
- Specified by:
getLatestOffsetRecords
in interfaceKafkaRecordBatch<K,T>
- Returns:
- map of records with latest offset by topic partition
-
getMetadata
public Metadata getMetadata()
- Specified by:
getMetadata
in interfaceMessage<K>
- Returns:
- The set of metadata attached to this message, potentially empty.
-
getAck
public Supplier<CompletionStage<Void>> getAck()
- Specified by:
getAck
in interfaceMessage<K>
- Returns:
- the supplier used to retrieve the acknowledgement
CompletionStage
.
-
getNack
public Function<Throwable,CompletionStage<Void>> getNack()
-
ack
public CompletionStage<Void> ack()
Description copied from interface:Message
Acknowledge this message.
-
nack
public CompletionStage<Void> nack(Throwable reason, Metadata metadata)
Description copied from interface:Message
Acknowledge negatively this message.nack
is used to indicate that the processing of a message failed. The reason is passed as parameter. Additional metadata may be provided that the connector can use when nacking the message. The interpretation of metadata is connector-specific.- Specified by:
nack
in interfaceMessage<K>
- Parameters:
reason
- the reason of the nack, must not benull
metadata
- additional nack metadata the connector may use, may benull
- Returns:
- a completion stage completed when the message is negative-acknowledgement has completed. If the negative acknowledgement fails, the completion stage propagates the failure.
-
-