Class AbstractAmqpStrategy
java.lang.Object
io.aiven.kafka.connect.amqp.sink.strategy.AbstractAmqpStrategy
- All Implemented Interfaces:
Strategy
- Direct Known Subclasses:
AmqpBodyFmt,AmqpRawFmt
Base implementation for AMQP strategies. Handles reporting when messages have been confirmed as
sent to AMQP destination.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA mapping for AMQP trackers to SinkRecords. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final EncoderDecoderThe Encoder/Decoder to useprotected final ErrantRecordHandlerThe handler for failed messagesprotected final org.apache.qpid.protonj2.client.SenderThe sender to send AMQP messages -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractAmqpStrategy(org.apache.qpid.protonj2.client.Sender sender, ErrantRecordHandler errantRecordHandler) Constructs a strategy with the specified sender and errant record handler. -
Method Summary
Modifier and TypeMethodDescriptionvoidflush(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.voidwrite(org.apache.kafka.connect.sink.SinkRecord sinkRecord) Writes a single sinkRecord.
-
Field Details
-
encoderDecoder
The Encoder/Decoder to use -
sender
protected final org.apache.qpid.protonj2.client.Sender senderThe sender to send AMQP messages -
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:StrategyWrites a single sinkRecord. Any errors encountered in writing should be reported via anErrantRecordHandler. -
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:StrategyAdjust the currentOffsets to commit. This method should return the highest offset for the topic/partition that should be committed. By default, this method callsStrategy.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 aSinkTask. -
flush
public void flush(Map<org.apache.kafka.common.TopicPartition, org.apache.kafka.clients.consumer.OffsetAndMetadata> currentOffsets) Description copied from interface:StrategyFlushes 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.
-