Document Listeners
Receive notifications when Document batches have been processed.
The DocumentListener
interface allows your custom code to be alerted when batches of Document sections have been processed or when the whole batch of Documents has been completed.
public interface DocumentListener {
default void documentBatchIngestStarted(List<Document> batch) {};
default void documentBatchIngestFinished(List<Document> batch) {};
default void documentIngestionComplete(List<List<Document>> batch) {};
}
Here's a very simple pseudo-code example within a tool where we are taking a file from the filesystem, ingesting it through our ContentRetriever and waiting for everything to be completely finished:
AtomicBoolean finishedLoading = new AtomicBoolean(false);
public void doWork() {
byte[] byteArray = file.getContentAsByteArray();
contentRetriever.ingestDocument(fileName, byteArray);
while (!finishedLoading.get()) {
log.info("Still loading...");
Thread.sleep(2500);
}
}
@Override
public void documentIngestionComplete(List<List<Document>> batch) {
log.info("Finished processing demand attachments. Ready to continue.");
finishedLoading.set(true);
}
Other use cases might use these listeners to call a webhook or send an actual notification.
Last updated
Was this helpful?