I do have batch jobs that perform chunk processing. This loop usually continues until the Reader has no more items to read and thus returns null. Or if at any point an Exception is thrown. In this case the batch job fails and the current transaction will be rolled back.
Now I have a generic Reader, e.g. JDBCReader to read from database, and some processor and writer. And I experience that either the processor or the writer can detect when no more records shall be read. But the reader does not know. You may consider this to be a “quota limit reached” in my application.
How can the processor or the writer exit the chunk processing loop without failing the job and thus resetting the last transaction?