Class AbstractAmqpStrategy

java.lang.Object
io.aiven.kafka.connect.amqp.sink.strategy.AbstractAmqpStrategy
All Implemented Interfaces:
Strategy
Direct Known Subclasses:
AmqpBodyFmt, AmqpRawFmt

public abstract class AbstractAmqpStrategy extends Object implements Strategy
Base implementation for AMQP strategies. Handles reporting when messages have been confirmed as sent to AMQP destination.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    A mapping for AMQP trackers to SinkRecords.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final EncoderDecoder
    The Encoder/Decoder to use
    protected final ErrantRecordHandler
    The handler for failed messages
    protected final org.apache.qpid.protonj2.client.Sender
    The sender to send AMQP messages
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractAmqpStrategy(org.apache.qpid.protonj2.client.Sender sender, ErrantRecordHandler errantRecordHandler)
    Constructs a strategy with the specified sender and errant record handler.
  • 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.
    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.
    void
    write(org.apache.kafka.connect.sink.SinkRecord sinkRecord)
    Writes a single sinkRecord.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.aiven.kafka.connect.amqp.sink.strategy.Strategy

    write
  • Field Details

    • encoderDecoder

      protected final EncoderDecoder encoderDecoder
      The Encoder/Decoder to use
    • sender

      protected final org.apache.qpid.protonj2.client.Sender sender
      The sender to send AMQP messages
    • errantRecordHandler

      protected final ErrantRecordHandler errantRecordHandler
      The handler for failed messages
  • Constructor Details

    • AbstractAmqpStrategy

      protected AbstractAmqpStrategy(org.apache.qpid.protonj2.client.Sender sender, ErrantRecordHandler errantRecordHandler)
      Constructs a strategy with the specified sender and errant record handler.
      Parameters:
      sender - the Sender to use.
      errantRecordHandler - The errant record handler to use.
  • Method Details

    • write

      public void write(org.apache.kafka.connect.sink.SinkRecord sinkRecord)
      Description copied from interface: Strategy
      Writes a single sinkRecord. Any errors encountered in writing should be reported via an ErrantRecordHandler.
      Specified by:
      write in interface Strategy
      Parameters:
      sinkRecord - the sink record to write.
    • preCommit

      public 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)
      Description copied from interface: Strategy
      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 Strategy.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.
      Specified by:
      preCommit in interface Strategy
      Parameters:
      currentOffsets - the offsets to commit.
      Returns:
      a map of committable topic/partition/offset values.
    • flush

      public void flush(Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> currentOffsets)
      Description copied from interface: Strategy
      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.
      Specified by:
      flush in interface Strategy
      Parameters:
      currentOffsets - the highest offset for each topic/partition that should be written.