M7 Bootstrap, Startvalidierung und Exit-Code-Verhalten finalisiert
This commit is contained in:
+12
-17
@@ -159,13 +159,19 @@ public class DefaultBatchRunProcessingUseCase implements BatchRunProcessingUseCa
|
||||
/**
|
||||
* Loads candidates and processes them one by one.
|
||||
* <p>
|
||||
* Tracks whether any document-level persistence failures occur during processing.
|
||||
* A persistence failure for a single document causes the overall batch outcome
|
||||
* to be FAILURE instead of SUCCESS.
|
||||
* Document-level failures — including content errors, transient technical errors,
|
||||
* and individual persistence failures — do not affect the batch outcome. The batch
|
||||
* completes with {@link BatchRunOutcome#SUCCESS} as long as the source folder is accessible
|
||||
* and the processing loop runs to completion without a hard infrastructure error.
|
||||
* Document-level persistence failures are logged by the coordinator and retried in
|
||||
* subsequent runs; they must not escalate to a hard batch failure.
|
||||
* <p>
|
||||
* Only a hard source folder access failure ({@link SourceDocumentAccessException}) prevents
|
||||
* the batch from running at all, in which case {@link BatchRunOutcome#FAILURE} is returned.
|
||||
*
|
||||
* @param context the current batch run context
|
||||
* @return SUCCESS if all candidates were processed without persistence failures,
|
||||
* FAILURE if source access fails or any document-level persistence failure occurred
|
||||
* @return {@link BatchRunOutcome#SUCCESS} after all candidates have been processed,
|
||||
* or {@link BatchRunOutcome#FAILURE} if the source folder is inaccessible
|
||||
*/
|
||||
private BatchRunOutcome processCandidates(BatchRunContext context) {
|
||||
List<SourceDocumentCandidate> candidates;
|
||||
@@ -177,24 +183,13 @@ public class DefaultBatchRunProcessingUseCase implements BatchRunProcessingUseCa
|
||||
}
|
||||
logger.info("Found {} PDF candidate(s) in source folder.", candidates.size());
|
||||
|
||||
// Track whether any document-level persistence failures occurred
|
||||
boolean anyPersistenceFailure = false;
|
||||
|
||||
// Process each candidate
|
||||
for (SourceDocumentCandidate candidate : candidates) {
|
||||
if (!processCandidate(candidate, context)) {
|
||||
anyPersistenceFailure = true;
|
||||
}
|
||||
processCandidate(candidate, context);
|
||||
}
|
||||
|
||||
logger.info("Batch run completed. Processed {} candidate(s). RunId: {}",
|
||||
candidates.size(), context.runId());
|
||||
|
||||
if (anyPersistenceFailure) {
|
||||
logger.warn("Batch run completed with document-level persistence failure(s).");
|
||||
return BatchRunOutcome.FAILURE;
|
||||
}
|
||||
|
||||
return BatchRunOutcome.SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user