What is the difference between submit() and offer() in a SubmissionPublisher (Java Reactive Streams)

49 Views Asked by At

What I have read so far indicates the the submit() method is blocking "while resources for any subscriber are unavailable" (not sure what exactly that means).

Hence I tried the following:

    var publisher = new SubmissionPublisher<String>(ForkJoinPool.commonPool(), 1);
    for (int i = 0; i < publisher.getMaxBufferCapacity() + 2; i++) {
        publisher.submit("item" + i);
    }
    publisher.close();

So I am submitting 3 items, there is no subscriber and still there is no blocking happening. The for-loop exits after three loops.

So what is the difference between submit and offer, about which people write it would "not block"?

0

There are 0 best solutions below