Class ExportListener

java.lang.Object
com.marklogic.client.datamovement.ExportListener
All Implemented Interfaces:
BatchListener<QueryBatch>, QueryBatchListener
Direct Known Subclasses:
ExportToWriterListener

public class ExportListener extends Object implements QueryBatchListener

Reads 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.

For example:

     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.