Class VerifiableSourceTask
- All Implemented Interfaces:
Task
If logging is left enabled, log output on stdout can be easily ignored by checking whether a given line is valid JSON.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.kafka.connect.source.SourceTask
SourceTask.TransactionBoundary -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class org.apache.kafka.connect.source.SourceTask
TRANSACTION_BOUNDARY_CONFIG -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcommitRecord(SourceRecord record, RecordMetadata metadata) Commit an individualSourceRecordwhen the callback from the producer client is received.poll()Poll this source task for new records.voidStart the Task.voidstop()Signal this SourceTask to stop.version()Get the version of this task.Methods inherited from class org.apache.kafka.connect.source.SourceTask
commit, initialize
-
Field Details
-
NAME_CONFIG
- See Also:
-
ID_CONFIG
- See Also:
-
TOPIC_CONFIG
- See Also:
-
THROUGHPUT_CONFIG
- See Also:
-
COMPLETE_RECORD_DATA_CONFIG
- See Also:
-
-
Constructor Details
-
VerifiableSourceTask
public VerifiableSourceTask()
-
-
Method Details
-
version
Description 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
-
start
Description copied from class:SourceTaskStart the Task. This should handle any configuration parsing and one-time setup of the task.- Specified by:
startin interfaceTask- Specified by:
startin classSourceTask- Parameters:
props- initial configuration
-
poll
Description copied from class:SourceTaskPoll this source task for new records. If no data is currently available, this method should block but return control to the caller regularly (by returningnull) in order for the task to transition to thePAUSEDstate if requested to do so.The task will be
stoppedon a separate thread, and when that happens this method is expected to unblock, quickly finish up any remaining processing, and return.- Specified by:
pollin classSourceTask- Returns:
- a list of source records
-
commitRecord
Description copied from class:SourceTaskCommit an individual
SourceRecordwhen the callback from the producer client is received. This method is also called when a record is filtered by a transformation or when "errors.tolerance" is set to "all" and thus will never be ACK'd by a broker. In both casesmetadatawill be null.SourceTasks are not required to implement this functionality; Kafka Connect will record offsets automatically. This hook is provided for systems that also need to store offsets internally in their own system.
The default implementation is a nop. It is not necessary to implement the method.
- Overrides:
commitRecordin classSourceTask- Parameters:
record-SourceRecordthat was successfully sent via the producer, filtered by a transformation, or dropped on producer exceptionmetadata-RecordMetadatarecord metadata returned from the broker, or null if the record was filtered or if producer exceptions are ignored
-
stop
public void stop()Description copied from class:SourceTaskSignal this SourceTask to stop. In SourceTasks, this method only needs to signal to the task that it should stop trying to poll for new data and interrupt any outstanding poll() requests. It is not required that the task has fully stopped. Note that this method necessarily may be invoked from a different thread thanSourceTask.poll()andSourceTask.commit().For example, if a task uses a
Selectorto receive data over the network, this method could set a flag that will forceSourceTask.poll()to exit immediately and invokewakeup()to interrupt any ongoing requests.- Specified by:
stopin interfaceTask- Specified by:
stopin classSourceTask
-