Package com.mongodb.kafka.connect.sink
Class MongoSinkTask
- java.lang.Object
-
- org.apache.kafka.connect.sink.SinkTask
-
- com.mongodb.kafka.connect.sink.MongoSinkTask
-
- All Implemented Interfaces:
org.apache.kafka.connect.connector.Task
public class MongoSinkTask extends org.apache.kafka.connect.sink.SinkTask
-
-
Constructor Summary
Constructors Constructor Description MongoSinkTask()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidflush(java.util.Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> currentOffsets)Flush all records that have beenput(Collection)for the specified topic-partitions.voidput(java.util.Collection<org.apache.kafka.connect.sink.SinkRecord> records)Put the records in the sink.voidstart(java.util.Map<java.lang.String,java.lang.String> props)Start the Task.voidstop()Perform any cleanup to stop this task.java.lang.Stringversion()
-
-
-
Method Detail
-
version
public java.lang.String version()
-
start
public void start(java.util.Map<java.lang.String,java.lang.String> props)
Start the Task. This should handle any configuration parsing and one-time setup of the task.- Specified by:
startin interfaceorg.apache.kafka.connect.connector.Task- Specified by:
startin classorg.apache.kafka.connect.sink.SinkTask- Parameters:
props- initial configuration
-
put
public void put(java.util.Collection<org.apache.kafka.connect.sink.SinkRecord> records)
Put the records in the sink. Usually this should send the records to the sink asynchronously and immediately return.If this operation fails, the SinkTask may throw a
RetriableExceptionto indicate that the framework should attempt to retry the same call again. Other exceptions will cause the task to be stopped immediately.SinkTaskContext.timeout(long)can be used to set the maximum time before the batch will be retried.- Specified by:
putin classorg.apache.kafka.connect.sink.SinkTask- Parameters:
records- the set of records to send
-
flush
public void flush(java.util.Map<org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata> currentOffsets)
Flush all records that have beenput(Collection)for the specified topic-partitions.- Overrides:
flushin classorg.apache.kafka.connect.sink.SinkTask- Parameters:
currentOffsets- the current offset state as of the last call toput(Collection)}, provided for convenience but could also be determined by tracking all offsets included in theSinkRecords passed toput(java.util.Collection<org.apache.kafka.connect.sink.SinkRecord>).
-
stop
public void stop()
Perform any cleanup to stop this task. In SinkTasks, this method is invoked only once outstanding calls to other methods have completed (e.g.,put(Collection)has returned) and a finalflush(Map)and offset commit has completed. Implementations of this method should only need to perform final cleanup operations, such as closing network connections to the sink system.- Specified by:
stopin interfaceorg.apache.kafka.connect.connector.Task- Specified by:
stopin classorg.apache.kafka.connect.sink.SinkTask
-
-