Class MessageConsumer<T>
- java.lang.Object
-
- io.vertx.rxjava.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(io.vertx.core.Handler<io.vertx.rxjava.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(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)method or by calling thehandler(io.vertx.core.Handler<io.vertx.rxjava.core.eventbus.Message<T>>)with a null value..originalnon RX-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(MessageConsumer delegate)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()voidcompletionHandler()Optional method which can be called to indicate when the registration has been propagated across the cluster.voidcompletionHandler(Handler<AsyncResult<Void>> completionHandler)Optional method which can be called to indicate when the registration has been propagated across the cluster.MessageConsumer<T>endHandler(Handler<Void> endHandler)Set an end handler.booleanequals(Object o)MessageConsumer<T>exceptionHandler(Handler<Throwable> handler)Set an exception handler on the read stream.MessageConsumer<T>fetch(long amount)Fetch the specifiedamountof elements.MessageConsumergetDelegate()intgetMaxBufferedMessages()MessageConsumer<T>handler(Handler<Message<T>> handler)Set a data handler.inthashCode()booleanisRegistered()static <T> MessageConsumer<T>newInstance(MessageConsumer arg)static <T> MessageConsumer<T>newInstance(MessageConsumer arg, TypeArg<T> __typeArg_T)MessageConsumer<T>pause()Pause theReadStream, it sets the buffer infetchmode and clears the actual demand.Pipe<Message<T>>pipe()Pause this stream and return a to transfer the elements of this stream to a destination .voidpipeTo(WriteStream<Message<T>> dst)Pipe thisReadStreamto theWriteStream.voidpipeTo(WriteStream<Message<T>> dst, Handler<AsyncResult<Void>> handler)Pipe thisReadStreamto theWriteStream.MessageConsumer<T>resume()Resume reading, and sets the buffer inflowingmode.rx.Single<Void>rxCompletionHandler()Optional method which can be called to indicate when the registration has been propagated across the cluster.rx.Single<Void>rxPipeTo(WriteStream<Message<T>> dst)Pipe thisReadStreamto theWriteStream.rx.Single<Void>rxUnregister()Unregisters the handler which created this registrationMessageConsumer<T>setMaxBufferedMessages(int maxBufferedMessages)Set the number of messages this registration will buffer when this stream is paused.rx.Observable<Message<T>>toObservable()StringtoString()voidunregister()Unregisters the handler which created this registrationvoidunregister(Handler<AsyncResult<Void>> completionHandler)Unregisters the handler which created this registration
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<MessageConsumer> __TYPE_ARG
-
-
Constructor Detail
-
MessageConsumer
public MessageConsumer(MessageConsumer delegate)
-
-
Method Detail
-
getDelegate
public MessageConsumer getDelegate()
- Specified by:
getDelegatein interfaceReadStream<T>- Specified by:
getDelegatein interfaceStreamBase
-
toObservable
public rx.Observable<Message<T>> toObservable()
- Specified by:
toObservablein interfaceReadStream<T>
-
pipe
public Pipe<Message<T>> pipe()
Pause this stream and return a to transfer the elements of this stream to a destination . The stream will be resumed when the pipe will be wired to aWriteStream.- Specified by:
pipein interfaceReadStream<T>- Returns:
- a pipe
-
pipeTo
public void pipeTo(WriteStream<Message<T>> dst, Handler<AsyncResult<Void>> handler)
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.- Specified by:
pipeToin interfaceReadStream<T>- Parameters:
dst- the destination write streamhandler-
-
pipeTo
public 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.- Specified by:
pipeToin interfaceReadStream<T>- Parameters:
dst- the destination write stream
-
rxPipeTo
public rx.Single<Void> rxPipeTo(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.- Specified by:
rxPipeToin interfaceReadStream<T>- Parameters:
dst- the destination write stream- Returns:
-
exceptionHandler
public MessageConsumer<T> exceptionHandler(Handler<Throwable> handler)
Description copied from interface:ReadStreamSet an exception handler on the read stream.- Specified by:
exceptionHandlerin interfaceReadStream<T>- Specified by:
exceptionHandlerin interfaceStreamBase- Parameters:
handler- the exception handler- Returns:
- a reference to this, so the API can be used fluently
-
handler
public MessageConsumer<T> handler(Handler<Message<T>> handler)
Description copied from interface:ReadStreamSet a data handler. As data is read, the handler will be called with the data.- Specified by:
handlerin interfaceReadStream<T>- Returns:
- a reference to this, so the API can be used fluently
-
pause
public MessageConsumer<T> pause()
Description copied from interface:ReadStreamPause theReadStream, it sets the buffer infetchmode and clears the actual demand.While it's paused, no data will be sent to the data
handler.- Specified by:
pausein interfaceReadStream<T>- Returns:
- a reference to this, so the API can be used fluently
-
resume
public MessageConsumer<T> resume()
Description copied from interface:ReadStreamResume reading, and sets the buffer inflowingmode. If theReadStreamhas been paused, reading will recommence on it.- Specified by:
resumein interfaceReadStream<T>- Returns:
- a reference to this, so the API can be used fluently
-
fetch
public MessageConsumer<T> fetch(long amount)
Description copied from interface:ReadStreamFetch the specifiedamountof elements. If theReadStreamhas been paused, reading will recommence with the specifiedamountof items, otherwise the specifiedamountwill be added to the current stream demand.- Specified by:
fetchin interfaceReadStream<T>- Returns:
- a reference to this, so the API can be used fluently
-
endHandler
public MessageConsumer<T> endHandler(Handler<Void> endHandler)
Description copied from interface:ReadStreamSet an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.- Specified by:
endHandlerin interfaceReadStream<T>- Returns:
- a reference to this, so the API can be used fluently
-
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)
Set the number of messages this registration will buffer when this stream is paused. The default value is1000.When a new value is set, buffered messages may be discarded to reach the new value. The most recent messages will be kept.
- 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 void completionHandler(Handler<AsyncResult<Void>> completionHandler)
Optional method which can be called to indicate when the registration has been propagated across the cluster.- Parameters:
completionHandler- the completion handler
-
completionHandler
public void completionHandler()
Optional method which can be called to indicate when the registration has been propagated across the cluster.
-
rxCompletionHandler
public rx.Single<Void> rxCompletionHandler()
Optional method which can be called to indicate when the registration has been propagated across the cluster.- Returns:
-
unregister
public void unregister(Handler<AsyncResult<Void>> completionHandler)
Unregisters the handler which created this registration- Parameters:
completionHandler- the handler called when the unregister is done. For example in a cluster when all nodes of the event bus have been unregistered.
-
unregister
public void unregister()
Unregisters the handler which created this registration
-
rxUnregister
public rx.Single<Void> rxUnregister()
Unregisters the handler which created this registration- Returns:
-
newInstance
public static <T> MessageConsumer<T> newInstance(MessageConsumer arg)
-
newInstance
public static <T> MessageConsumer<T> newInstance(MessageConsumer arg, TypeArg<T> __typeArg_T)
-
-