Package org.apache.kafka.connect.tools
Class VerifiableSinkTask
java.lang.Object
org.apache.kafka.connect.sink.SinkTask
org.apache.kafka.connect.tools.VerifiableSinkTask
- All Implemented Interfaces:
- Task
Counterpart to 
VerifiableSourceTask that consumes records and logs information about each to stdout. This
 allows validation of processing of messages by sink tasks on distributed workers even in the face of worker restarts
 and failures. This task relies on the offset management provided by the Kafka Connect framework and therefore can detect
 bugs in its implementation.- 
Field SummaryFieldsFields inherited from class org.apache.kafka.connect.sink.SinkTaskTOPICS_CONFIG, TOPICS_REGEX_CONFIG
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidflush(Map<TopicPartition, OffsetAndMetadata> offsets) Flush all records that have beenSinkTask.put(Collection)for the specified topic-partitions.voidput(Collection<SinkRecord> records) Put the records in the sink.voidStart the Task.voidstop()Perform any cleanup to stop this task.version()Get the version of this task.Methods inherited from class org.apache.kafka.connect.sink.SinkTaskclose, initialize, onPartitionsAssigned, onPartitionsRevoked, open, preCommit
- 
Field Details- 
NAME_CONFIG- See Also:
 
- 
ID_CONFIG- See Also:
 
 
- 
- 
Constructor Details- 
VerifiableSinkTaskpublic VerifiableSinkTask()
 
- 
- 
Method Details- 
versionDescription copied from interface:TaskGet the version of this task. Usually this should be the same as the correspondingConnectorclass's version.- Returns:
- the version, formatted as a String
 
- 
startDescription copied from class:SinkTaskStart the Task. This should handle any configuration parsing and one-time setup of the task.
- 
putDescription copied from class:SinkTaskPut the records in the sink. This should either write them to the downstream system or batch them for later writing. If this method returns before the records are written to the downstream system, the task must implementSinkTask.flush(Map)orSinkTask.preCommit(Map)to ensure that offsets are only committed for records that have been written to the downstream system (hence avoiding data loss during failures).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.
- 
flushDescription copied from class:SinkTaskFlush all records that have beenSinkTask.put(Collection)for the specified topic-partitions.- Overrides:
- flushin class- SinkTask
- Parameters:
- offsets- the current offset state as of the last call to- SinkTask.put(Collection), provided for convenience but could also be determined by tracking all offsets included in the- SinkRecords passed to- SinkTask.put(java.util.Collection<org.apache.kafka.connect.sink.SinkRecord>). Note that the topic, partition and offset here correspond to the original Kafka topic partition and offset, before any- transformationshave been applied. These can be tracked by the task through the- SinkRecord.originalTopic(),- SinkRecord.originalKafkaPartition()and- SinkRecord.originalKafkaOffset()methods.
 
- 
stoppublic void stop()Description copied from class:SinkTaskPerform any cleanup to stop this task. In SinkTasks, this method is invoked only once outstanding calls to other methods have completed (e.g.,SinkTask.put(Collection)has returned) and a finalSinkTask.flush(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.
 
-