Interface Strategy
- All Known Implementing Classes:
AbstractAmqpStrategy,AmqpBodyFmt,AmqpRawFmt
public interface Strategy
Definition of a write strategy.
-
Method Summary
Modifier and TypeMethodDescriptionvoidflush(Map<org.apache.kafka.common.TopicPartition, org.apache.kafka.clients.consumer.OffsetAndMetadata> currentOffsets) Flushes the data to the storage.default Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> preCommit(Map<org.apache.kafka.common.TopicPartition, org.apache.kafka.clients.consumer.OffsetAndMetadata> currentOffsets) Adjust the currentOffsets to commit.default voidwrite(Collection<org.apache.kafka.connect.sink.SinkRecord> records) Writes multiple SinkRecords.voidwrite(org.apache.kafka.connect.sink.SinkRecord sinkRecord) Writes a single sinkRecord.
-
Method Details
-
write
void write(org.apache.kafka.connect.sink.SinkRecord sinkRecord) Writes a single sinkRecord. Any errors encountered in writing should be reported via anErrantRecordHandler.- Parameters:
sinkRecord- the sink record to write.
-
write
Writes multiple SinkRecords. Any errors encountered in writing should be reported via anErrantRecordHandler. By default, this method iterates over the collection callingwrite(SinkRecord). This method can be overridden for strategies that handle bulk writing and/or want to report bulk errant messages.- Parameters:
records- the records to write.
-
preCommit
default Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> preCommit(Map<org.apache.kafka.common.TopicPartition, org.apache.kafka.clients.consumer.OffsetAndMetadata> currentOffsets) Adjust the currentOffsets to commit. This method should return the highest offset for the topic/partition that should be committed. By default, this method callsflush(java.util.Map<org.apache.kafka.common.TopicPartition, org.apache.kafka.clients.consumer.OffsetAndMetadata>)and returns the entire list of candidates that kafka is suggesting. This is the default behavior for aSinkTask.- Parameters:
currentOffsets- the offsets to commit.- Returns:
- a map of committable topic/partition/offset values.
-
flush
void flush(Map<org.apache.kafka.common.TopicPartition, org.apache.kafka.clients.consumer.OffsetAndMetadata> currentOffsets) Flushes the data to the storage. For strategies that stream the data there may not be a need for aflushmethod in which case this method amy be a no-op.- Parameters:
currentOffsets- the highest offset for each topic/partition that should be written.
-