@Override
    public void onMessage(Message m, AckToken token) {
        if (m instanceof PutDocumentMessage) {
            PutDocumentMessage pm = (PutDocumentMessage)m;

            onDocument(pm.getDocumentPut().getDocument(), pm.getTimestamp());
        } else if (m instanceof RemoveDocumentMessage) {
            RemoveDocumentMessage rm = (RemoveDocumentMessage)m;
            onRemove(rm.getDocumentId());
        } else {
            throw new UnsupportedOperationException("Received unsupported message " + m.toString() + " to dump visitor data handler. This handler only accepts Put and Remove");
        }
        ack(token);
    }
<p>Implementation of VisitorDataHandler which invokes onDocument() for each
received document and onRemove() for each document id that was returned as
part of a remove entry. The latter only applies if the visitor was run with
visitRemoves enabled.</p>

<p>NOTE: onDocument and onRemove may be called in a re-entrant manner, as
these run on top of a thread pool. Any mutation of shared state must be
appropriately synchronized.</p>
documentapi/src/main/java/com/yahoo/documentapi/DumpVisitorDataHandler.java