Interface Strategy

All Known Implementing Classes:
AbstractAmqpStrategy, AmqpBodyFmt, AmqpRawFmt

public interface Strategy
Definition of a write strategy.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    flush(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 void
    write(Collection<org.apache.kafka.connect.sink.SinkRecord> records)
    Writes multiple SinkRecords.
    void
    write(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 an ErrantRecordHandler.
      Parameters:
      sinkRecord - the sink record to write.
    • write

      default void write(Collection<org.apache.kafka.connect.sink.SinkRecord> records)
      Writes multiple SinkRecords. Any errors encountered in writing should be reported via an ErrantRecordHandler. By default, this method iterates over the collection calling write(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 calls flush(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 a SinkTask.
      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 a flush method in which case this method amy be a no-op.
      Parameters:
      currentOffsets - the highest offset for each topic/partition that should be written.