Class MessageConsumer<T>
- java.lang.Object
-
- io.vertx.mutiny.core.eventbus.MessageConsumer<T>
-
- All Implemented Interfaces:
ReadStream<Message<T>>
,StreamBase
public class MessageConsumer<T> extends Object implements ReadStream<Message<T>>
An event bus consumer object representing a stream of message to anEventBus
address that can be read from.The
EventBus.consumer(java.lang.String)
orEventBus.localConsumer(java.lang.String)
creates a new consumer, the returned consumer is not yet registered against the event bus. Registration is effective after thehandler(java.util.function.Consumer<io.vertx.mutiny.core.eventbus.Message<T>>)
method is invoked.The consumer is unregistered from the event bus using the
NOTE: This class has been automatically generated from theunregister()
method or by calling thehandler(java.util.function.Consumer<io.vertx.mutiny.core.eventbus.Message<T>>)
with a null value..original
non Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<MessageConsumer>
__TYPE_ARG
TypeArg<T>
__typeArg_0
-
Constructor Summary
Constructors Constructor Description MessageConsumer(io.vertx.core.eventbus.MessageConsumer delegate)
MessageConsumer(io.vertx.core.eventbus.MessageConsumer delegate, TypeArg<T> typeArg_0)
MessageConsumer(Object delegate, TypeArg<T> typeArg_0)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
address()
ReadStream<T>
bodyStream()
io.smallrye.mutiny.Uni<Void>
completionHandler()
Optional method which can be called to indicate when the registration has been propagated across the cluster.Void
completionHandlerAndAwait()
Blocking variant ofcompletionHandler()
.void
completionHandlerAndForget()
Variant ofcompletionHandler()
that ignores the result of the operation.MessageConsumer<T>
endHandler(Runnable endHandler)
boolean
equals(Object o)
MessageConsumer<T>
exceptionHandler(Consumer<Throwable> handler)
MessageConsumer<T>
fetch(long amount)
io.vertx.core.eventbus.MessageConsumer
getDelegate()
int
getMaxBufferedMessages()
MessageConsumer<T>
handler(Consumer<Message<T>> handler)
int
hashCode()
boolean
isRegistered()
static <T> MessageConsumer<T>
newInstance(io.vertx.core.eventbus.MessageConsumer arg)
static <T> MessageConsumer<T>
newInstance(io.vertx.core.eventbus.MessageConsumer arg, TypeArg<T> __typeArg_T)
MessageConsumer<T>
pause()
Pipe<Message<T>>
pipe()
io.smallrye.mutiny.Uni<Void>
pipeTo(WriteStream<Message<T>> dst)
Pipe thisReadStream
to theWriteStream
.Void
pipeToAndAwait(WriteStream<Message<T>> dst)
Blocking variant ofReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream)
.void
pipeToAndForget(WriteStream<Message<T>> dst)
Variant ofReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream)
that ignores the result of the operation.MessageConsumer<T>
resume()
MessageConsumer<T>
setMaxBufferedMessages(int maxBufferedMessages)
Iterable<Message<T>>
toBlockingIterable()
Stream<Message<T>>
toBlockingStream()
io.smallrye.mutiny.Multi<Message<T>>
toMulti()
String
toString()
io.smallrye.mutiny.Uni<Void>
unregister()
Unregisters the handler which created this registrationVoid
unregisterAndAwait()
Blocking variant ofunregister()
.void
unregisterAndForget()
Variant ofunregister()
that ignores the result of the operation.
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<MessageConsumer> __TYPE_ARG
-
-
Method Detail
-
getDelegate
public io.vertx.core.eventbus.MessageConsumer getDelegate()
- Specified by:
getDelegate
in interfaceReadStream<T>
- Specified by:
getDelegate
in interfaceStreamBase
-
pipeTo
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> pipeTo(WriteStream<Message<T>> dst)
Pipe thisReadStream
to theWriteStream
.Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Once this stream has ended or failed, the write stream will be ended and the
handler
will be called with the result.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Specified by:
pipeTo
in interfaceReadStream<T>
- Parameters:
dst
- the destination write stream- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
pipeToAndAwait
public Void pipeToAndAwait(WriteStream<Message<T>> dst)
Blocking variant ofReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream)
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Specified by:
pipeToAndAwait
in interfaceReadStream<T>
- Parameters:
dst
- the destination write stream- Returns:
- the Void instance produced by the operation.
-
pipeToAndForget
public void pipeToAndForget(WriteStream<Message<T>> dst)
Variant ofReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream)
that ignores the result of the operation.This method subscribes on the result of
ReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream)
but you don't need to compose it with other operations.- Specified by:
pipeToAndForget
in interfaceReadStream<T>
- Parameters:
dst
- the destination write stream
-
exceptionHandler
public MessageConsumer<T> exceptionHandler(Consumer<Throwable> handler)
- Specified by:
exceptionHandler
in interfaceReadStream<T>
- Specified by:
exceptionHandler
in interfaceStreamBase
- Parameters:
handler
- the exception handler- Returns:
-
handler
public MessageConsumer<T> handler(Consumer<Message<T>> handler)
- Specified by:
handler
in interfaceReadStream<T>
- Returns:
-
pause
public MessageConsumer<T> pause()
- Specified by:
pause
in interfaceReadStream<T>
- Returns:
- a reference to this, so the API can be used fluently
-
resume
public MessageConsumer<T> resume()
- Specified by:
resume
in interfaceReadStream<T>
- Returns:
- a reference to this, so the API can be used fluently
-
fetch
public MessageConsumer<T> fetch(long amount)
- Specified by:
fetch
in interfaceReadStream<T>
- Returns:
- a reference to this, so the API can be used fluently
-
endHandler
public MessageConsumer<T> endHandler(Runnable endHandler)
- Specified by:
endHandler
in interfaceReadStream<T>
- Returns:
-
bodyStream
public ReadStream<T> bodyStream()
- Returns:
- a read stream for the body of the message stream.
-
isRegistered
public boolean isRegistered()
- Returns:
- true if the current consumer is registered
-
address
public String address()
- Returns:
- The address the handler was registered with.
-
setMaxBufferedMessages
public MessageConsumer<T> setMaxBufferedMessages(int maxBufferedMessages)
- Parameters:
maxBufferedMessages
- the maximum number of messages that can be buffered- Returns:
- this registration
-
getMaxBufferedMessages
public int getMaxBufferedMessages()
- Returns:
- the maximum number of messages that can be buffered when this stream is paused
-
completionHandler
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> completionHandler()
Optional method which can be called to indicate when the registration has been propagated across the cluster.Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
completionHandlerAndAwait
public Void completionHandlerAndAwait()
Blocking variant ofcompletionHandler()
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Returns:
- the Void instance produced by the operation.
-
completionHandlerAndForget
public void completionHandlerAndForget()
Variant ofcompletionHandler()
that ignores the result of the operation.This method subscribes on the result of
completionHandler()
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromcompletionHandler()
but you don't need to compose it with other operations.
-
unregister
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> unregister()
Unregisters the handler which created this registrationUnlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
unregisterAndAwait
public Void unregisterAndAwait()
Blocking variant ofunregister()
.This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).
- Returns:
- the Void instance produced by the operation.
-
unregisterAndForget
public void unregisterAndForget()
Variant ofunregister()
that ignores the result of the operation.This method subscribes on the result of
unregister()
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromunregister()
but you don't need to compose it with other operations.
-
toMulti
@CheckReturnValue public io.smallrye.mutiny.Multi<Message<T>> toMulti()
- Specified by:
toMulti
in interfaceReadStream<T>
-
newInstance
public static <T> MessageConsumer<T> newInstance(io.vertx.core.eventbus.MessageConsumer arg)
-
newInstance
public static <T> MessageConsumer<T> newInstance(io.vertx.core.eventbus.MessageConsumer arg, TypeArg<T> __typeArg_T)
-
-