...
Proposed Changes
- We'll add the
isClosing
method to theSinkTaskContext
as mentioned above. - We'll add the implementation for that to
WorkerSinkTaskContext
- We'll add a setter named
setClosingInProgress
toWorkerSinkTaskContext
that'll change the internal state - In
WorkerSinkTask.commitOffsets
:- If the closing parameter is set to
true
, we'll invokesetClosingInProgress
on the context totrue
. This will occur before the invocation ofpreCommit
. - Before
commitOffsets
returns, it will setClosingInProgress willsetClosingInProgress
back tofalse
.
- If the closing parameter is set to
- Add a note to the
preCommit
javadoc to indicate the importance of checkingSinkTaskContext.isClosed
when running,
This change will give preCommit the opportunity to provide some additional commits that it would like Kafka Connect to make before the task is fully shut down.
...
- We considered adding a closing parameter to preCommit, but that would be a breaking change for all connectors and would require them to change their code when upgrading to the next version of Connect. It would also break binary compabilityunless it was done very carefully. The additional complexity would buy us marginal extra value, if any at all, so we decided to go with the addition to the context object.