ConnectorLib C++ 25.1
ConnectorLib C++ SDK Programming Guide

# Ingest Result Handlers

When you ingest a document using the `Add`, `Replace`, `Remove` or `Update` methods, the ingest command is placed in a queue and the method returns immediately. ConnectorLib C++ takes care of batching, sending the commands, and dealing with any transitory problems communicating with the target.

As a result, the `Add`, `Replace`, `Remove` and `Update` methods never fail, even if there is a problem ingesting a document. To find out whether each document was ingested successfully, you can register an Ingest result handler:

           MyIngestResultHandler handler(task.log());
           task.ingester().addResultHandler(handler);

The class `MyIngestResultHandler` is a user defined function object. In this example it is constructed with a `Log`.

The result handler is called whenever a document is successfully ingested or when ingestion fails for a document. A simple result handler is shown here:

    class MyIngestResultHandler : public Ingester::ResultHandler
    {
        Log m_log;

    public:
        MyIngestResultHandler(const Log& log)
          : m_log(log)
        {}

        void operator()(const IngestTask& ingestTask)
        {
            if (ingestTask.status() == IngestTaskStatus::Done)
            {
                m_log.full("Document " + ingestTask.document().reference()
                    + ", ingest " + ingestTask.typeString() + " succeeded!");
            }
            else
            {
                m_log.full("Ingestion failed for " + ingestTask.document().reference());
            }
        }
    };

Ingest result handlers are useful when you want to update state information only when documents are ingested successfully. An example of a connector using an ingest result handler for this purpose is included in Make an Incremental Synchronize Action.

Copyright 2024 Open Text
Version 25.1 | Last updated January 2025

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: Knowledge Discovery ConnectorLib C++ 25.1

Topic Title: Ingest Result Handlers