V
- the value typepublic interface Publisher<V> extends AutoCloseable
NamedTopic
.
The factory method NamedTopic.createPublisher(Publisher.Option[])
allows one to specify
one or more Publisher.Option
s to configure the Publisher
.
Since the send(Object)
method is asynchronous, there is a flush()
that allows one to block until all outstanding
sent values
for the Publisher
have completed.
Modifier and Type | Interface and Description |
---|---|
static class |
Publisher.FailOnFull
The FailOnFull option indicates that the
CompletableFuture returned
from the send(V) operation should complete exceptionally
upon identifying that the topic is or has become full. |
static class |
Publisher.OnFailure
|
static interface |
Publisher.Option<V>
A marker interface to indicate that a class is a valid
Publisher.Option
for a Publisher . |
static class |
Publisher.OrderBy<V>
The OrderBy option specifies the ordering of async operations with respect
to one another.
|
static class |
Publisher.OrderById<V>
Publisher.OrderBy option ensures ordering of sent values across
all threads which share the same orderId . |
static class |
Publisher.OrderByNone<V>
Publisher.OrderBy option enforces no specific ordering between sent values allowing
for the greatest level of parallelism. |
static class |
Publisher.OrderByThread<V>
Publisher.OrderBy option which ensures that a sequence of sent values issued by a single thread will
complete in order. |
static class |
Publisher.OrderByValue<V>
Publisher.OrderBy option which computes the unit-of-order based on applying
constructor's orderIdFunction parameter on sent value . |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close this
Publisher . |
CompletableFuture<Void> |
flush()
Obtain a
CompletableFuture that will be complete when
all of the currently outstanding publish operations complete. |
FlowControl |
getFlowControl()
Return the
FlowControl object governing this publisher. |
void |
onClose(Runnable action)
Add an action to be executed when this
Publisher is closed. |
CompletableFuture<Void> |
send(V value)
Asynchronously publish the specified value to the topic.
|
CompletableFuture<Void> send(V value)
Cancellation
of the returned future
is best effort and is not guaranteed to stop the corresponding publication of the value.
value
- the value to add to the topicCompletableFuture
which can be used to identify
when the value has been delivered to the topicFlowControl getFlowControl()
FlowControl
object governing this publisher.CompletableFuture<Void> flush()
CompletableFuture
that will be complete when
all of the currently outstanding publish operations complete.
The returned CompletableFuture
will always complete
normally, even if the outstanding operations complete exceptionally.
CompletableFuture
that will be completed when
all of the currently outstanding publish operations are completevoid close()
Publisher
.
This is a blocking method and will wait until all outstanding
CompletableFuture
s returned from previous calls
to send(Object)
have completed before returning.
close
in interface AutoCloseable