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 anEventBusaddress 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..originalnon Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<MessageConsumer>__TYPE_ARGTypeArg<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 Stringaddress()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.VoidcompletionHandlerAndAwait()Blocking variant ofcompletionHandler().voidcompletionHandlerAndForget()Variant ofcompletionHandler()that ignores the result of the operation.MessageConsumer<T>endHandler(Runnable endHandler)booleanequals(Object o)MessageConsumer<T>exceptionHandler(Consumer<Throwable> handler)MessageConsumer<T>fetch(long amount)io.vertx.core.eventbus.MessageConsumergetDelegate()intgetMaxBufferedMessages()MessageConsumer<T>handler(Consumer<Message<T>> handler)inthashCode()booleanisRegistered()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 thisReadStreamto theWriteStream.VoidpipeToAndAwait(WriteStream<Message<T>> dst)Blocking variant ofio.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStream.>) voidpipeToAndForget(WriteStream<Message<T>> dst)Variant ofio.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStreamthat ignores the result of the operation.>) io.smallrye.mutiny.Uni<MessageConsumer<T>>registration()Unlike the bare Vert.x variant, this method returns aUni.MessageConsumer<T>registrationAndAwait()Blocking variant ofregistration().voidregistrationAndForget()Variant ofregistration()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()StringtoString()io.smallrye.mutiny.Uni<Void>unregister()Unregisters the handler which created this registrationVoidunregisterAndAwait()Blocking variant ofunregister().voidunregisterAndForget()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:
getDelegatein interfaceReadStream<T>- Specified by:
getDelegatein interfaceStreamBase
-
pipeTo
public io.smallrye.mutiny.Uni<Void> pipeTo(WriteStream<Message<T>> dst)
Pipe thisReadStreamto 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
handlerwill 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:
pipeToin interfaceReadStream<T>- Parameters:
dst- the destination write stream- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
pipeToAndAwait
public Void pipeToAndAwait(WriteStream<Message<T>> dst)
Blocking variant ofio.vertx.mutiny.core.streams.ReadStream#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:
pipeToAndAwaitin 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 ofio.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStreamthat ignores the result of the operation.>) This method subscribes on the result of
io.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStream, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from>) io.vertx.mutiny.core.streams.ReadStream#pipeTo(io.vertx.mutiny.core.streams.WriteStreambut you don't need to compose it with other operations.>) - Specified by:
pipeToAndForgetin interfaceReadStream<T>- Parameters:
dst- the destination write stream
-
exceptionHandler
public MessageConsumer<T> exceptionHandler(Consumer<Throwable> handler)
- Specified by:
exceptionHandlerin interfaceReadStream<T>- Specified by:
exceptionHandlerin interfaceStreamBase- Parameters:
handler- the exception handler- Returns:
-
handler
public MessageConsumer<T> handler(Consumer<Message<T>> handler)
- Specified by:
handlerin interfaceReadStream<T>- Returns:
-
pause
public MessageConsumer<T> pause()
- Specified by:
pausein interfaceReadStream<T>- Returns:
- a reference to this, so the API can be used fluently
-
resume
public MessageConsumer<T> resume()
- Specified by:
resumein interfaceReadStream<T>- Returns:
- a reference to this, so the API can be used fluently
-
fetch
public MessageConsumer<T> fetch(long amount)
- Specified by:
fetchin interfaceReadStream<T>- Returns:
- a reference to this, so the API can be used fluently
-
endHandler
public MessageConsumer<T> endHandler(Runnable endHandler)
- Specified by:
endHandlerin 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
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
unifiring 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.
-
registration
public io.smallrye.mutiny.Uni<MessageConsumer<T>> registration()
Unlike the bare Vert.x variant, this method returns a
Uni. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
unifiring the result of the operation when completed, or a failure if the operation failed.
-
registrationAndAwait
public MessageConsumer<T> registrationAndAwait()
Blocking variant ofregistration().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 MessageConsumer
instance produced by the operation.
-
registrationAndForget
public void registrationAndForget()
Variant ofregistration()that ignores the result of the operation.This method subscribes on the result of
registration(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromregistration()but you don't need to compose it with other operations.
-
unregister
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
unifiring 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
public io.smallrye.mutiny.Multi<Message<T>> toMulti()
- Specified by:
toMultiin 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)
-
-