@Override
    public void run() {
        while (!drain.get() || !operations.isEmpty()) {
            try {
                JsonStreamFeederExample.Operation op = operations.poll(1, TimeUnit.SECONDS);
                if(op == null) // no operations available
                    continue;
                log.info("Put document " + op.documentId);
                CompletableFuture<Result> promise;
                DocumentId docId = DocumentId.of(op.documentId);
                OperationParameters params = OperationParameters.empty();
                String json = op.documentFieldsJson;
                switch (op.type) {
                    case "put":
                        promise = feedClient.put(docId, json, params);
                        break;
                    case "remove":
                        promise = feedClient.remove(docId, params);
                        break;
                    case "update":
                        promise = feedClient.update(docId, json, params);
                        break;
                    default:
                        throw new IllegalArgumentException("Invalid operation: " + op.type);
                }
                promise.whenComplete((result, throwable) -> {
                    if (resultCounter.getAndIncrement() % 10 == 0) {
                        System.err.println(feedClient.stats());
                    }
                    if (throwable != null) {
                        System.err.printf("Failure for '%s': %s", docId, throwable);
                        throwable.printStackTrace();
                    }
                });
            } catch (InterruptedException e) {
                log.log(Level.SEVERE, "Got interrupt exception.", e);
                break;
            }
        }
        log.info("Shutting down feeding thread");
        this.feedClient.close();
        finishedDraining.countDown();
    }
Shutdown this feeder, waits until operations on queue is drained
vespa-feed-client-api/src/test/java/ai/vespa/feed/client/examples/JsonStreamFeederExample.java