public class VerifiableSourceTask extends SourceTask
If logging is left enabled, log output on stdout can be easily ignored by checking whether a given line is valid JSON.
SourceTask.TransactionBoundary
Modifier and Type | Field and Description |
---|---|
static String |
COMPLETE_RECORD_DATA_CONFIG |
static String |
ID_CONFIG |
static String |
NAME_CONFIG |
static String |
THROUGHPUT_CONFIG |
static String |
TOPIC_CONFIG |
context, TRANSACTION_BOUNDARY_CONFIG
Constructor and Description |
---|
VerifiableSourceTask() |
Modifier and Type | Method and Description |
---|---|
void |
commitRecord(SourceRecord record,
RecordMetadata metadata)
Commit an individual
SourceRecord when the callback from the producer client is received. |
List<SourceRecord> |
poll()
Poll this source task for new records.
|
void |
start(Map<String,String> props)
Start the Task.
|
void |
stop()
Signal this SourceTask to stop.
|
String |
version()
Get the version of this task.
|
commit, commitRecord, initialize
public static final String NAME_CONFIG
public static final String ID_CONFIG
public static final String TOPIC_CONFIG
public static final String THROUGHPUT_CONFIG
public static final String COMPLETE_RECORD_DATA_CONFIG
public String version()
Task
Connector
class's version.public void start(Map<String,String> props)
SourceTask
start
in interface Task
start
in class SourceTask
props
- initial configurationpublic List<SourceRecord> poll()
SourceTask
null
) in
order for the task to transition to the PAUSED
state if requested to do so.
The task will be stopped
on a separate thread, and when that happens
this method is expected to unblock, quickly finish up any remaining processing, and
return.
poll
in class SourceTask
public void commitRecord(SourceRecord record, RecordMetadata metadata)
SourceTask
Commit an individual SourceRecord
when 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 cases metadata
will 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 just calls SourceTask.commitRecord(SourceRecord)
, which is a nop by default. It is
not necessary to implement both methods.
commitRecord
in class SourceTask
record
- SourceRecord
that was successfully sent via the producer, filtered by a transformation, or dropped on producer exceptionmetadata
- RecordMetadata
record metadata returned from the broker, or null if the record was filtered or if producer exceptions are ignoredpublic void stop()
SourceTask
SourceTask.poll()
and
SourceTask.commit()
.
For example, if a task uses a Selector
to receive data over the network, this method
could set a flag that will force SourceTask.poll()
to exit immediately and invoke
wakeup()
to interrupt any ongoing requests.
stop
in interface Task
stop
in class SourceTask