public synchronized void flush() {
        verifyNotClosed();

        if (this.flushException != null) {
            throw this.flushException;
        }

        while (!this.completions.isEmpty())
            completeNext();
    }
Get the next offset for this topic/partition
clients/src/main/java/org/apache/kafka/clients/producer/MockProducer.java