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 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.void
put(java.util.Collection<org.apache.kafka.connect.sink.SinkRecord> records)
Put the records in the sink.void
start(java.util.Map<java.lang.String,java.lang.String> props)
Start the Task.void
stop()
Perform any cleanup to stop this task.java.lang.String
version()
-
-
-
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:
start
in interfaceorg.apache.kafka.connect.connector.Task
- Specified by:
start
in 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 aRetriableException
to 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:
put
in 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:
flush
in 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 theSinkRecord
s 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:
stop
in interfaceorg.apache.kafka.connect.connector.Task
- Specified by:
stop
in classorg.apache.kafka.connect.sink.SinkTask
-
-