BatchListener<QueryBatch>,
QueryBatchListenerExportToWriterListenerReads document contents (and optionally metadata) for each
batch, then sends each document to any listeners registered with
onDocumentReady
for further processing or writing to any target supported by Java.
Supports reading partial documents via transforms. Supports
exporting all documents at a consistent point-in-time using
withConsistentSnapshot.
QueryBatcher exportBatcher = moveMgr.newQueryBatcher(query)
.withConsistentSnapshot()
.onUrisReady(
new ExportListener()
.withConsistentSnapshot()
.onDocumentReady(doc -> {
logger.debug("Contents=[{}]", doc.getContentAs(String.class));
})
)
.onQueryFailure(exception -> exception.printStackTrace());
JobTicket ticket = moveMgr.startJob(exportBatcher);
exportBatcher.awaitCompletion();
moveMgr.stopJob(ticket);
By default only document contents are retrieved. If you would
also like metadata, make sure to call
withMetadataCategory to configure which categories
of metadata you desire.
As with all the provided listeners, this listener will not meet the needs of all applications but the source code for it should serve as helpful sample code so you can write your own custom listeners.
protected List<BatchFailureListener<QueryBatch>>protected DocumentPagegetDocs (QueryBatch batch)voidinitializeListener (QueryBatcher queryBatcher)onDocumentPageReady (Consumer<DocumentPage> listener)onDocumentReady (Consumer<DocumentRecord> listener)onFailure (BatchFailureListener<QueryBatch> listener)voidprocessEvent (QueryBatch batch)withMetadataCategory (DocumentManager.Metadata category)DocumentRecord.getMetadata
to listeners registered with onDocumentReady.withNonDocumentFormat (Format nonDocumentFormat)DocumentRecord.getMetadata
to listeners registered with onDocumentReady (assuming
withMetadataCategory has been called to request
specific metdata).withTransform (ServerTransform transform)
initializeListener in interface QueryBatchListenerqueryBatcher - the QueryBatcher which will call
this ListenerprocessEvent in
interface BatchListener<QueryBatch>
processEvent in interface QueryBatchListenerbatch - the batch of uris and some metadata about
the current status of the jobquery, not with an
Iterator.DocumentRecord.getMetadata
to listeners registered with onDocumentReady. To specify the format
for the metdata, call withNonDocumentFormat.category - the metadata category to retrieveDocumentRecord.getMetadata
to listeners registered with onDocumentReady (assuming
withMetadataCategory has been called to request
specific metdata). If setNonDocumentFormat is not called, the
server default format will be used.nonDocumentFormat - the format in which retrieve
the metadatatransform - the name of the transform already
installed in the REST serverQueryBatcher.onUrisReady instead.listener - the code which will process each
documentclose() does need to be invoked
on the DocumentPage; this class will handle
that.listener - the code which will process each page
of documentslistener - the code to run when a failure
occursCopyright (c) 2010-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.