@Override public void onMessage(Message m, AckToken token) {
                        Document document = null;
                        DocumentId removeId = null;
                        long persistedTimestamp = 0;
                        if (m instanceof PutDocumentMessage put) {
                            document = put.getDocumentPut().getDocument();
                            persistedTimestamp = put.getPersistedTimestamp();
                        } else if (parameters.visitRemoves() && m instanceof RemoveDocumentMessage remove) {
                            removeId = remove.getDocumentId();
                            persistedTimestamp = remove.getPersistedTimestamp();
                        } else {
                            throw new UnsupportedOperationException("Got unsupported message type: " + m.getClass().getName());
                        }
                        locallyReceivedDocCount.getAndAdd(1);
                        callback.onDocument(response,
                                            document,
                                            removeId,
                                            persistedTimestamp,
                                            () -> ack(token),
                                            errorMessage -> {
                                                error.set(errorMessage);
                                                controller.abort();
                                            });
                    }
Called at the end of response rendering, before generic status data is written. Called from a dedicated thread pool.
vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java