Top Description Methods
io.vertx.core.eventbus

public Interface MessageConsumer<T>

extends ReadStream<Message<T>>
Known Direct Implementers
io.vertx.core.eventbus.impl.MessageConsumerImpl
Annotations
@VertxGen
Imports
io.vertx.codegen.annotations.VertxGen, io.vertx.core.AsyncResult, .Future, .Handler, io.vertx.core.streams.ReadStream

An event bus consumer object representing a stream of message to an EventBus address that can be read from.

The EventBus#consumer(String) or EventBus#localConsumer(String) creates a new consumer, the returned consumer is not yet registered against the event bus. Registration is effective after the handler(io.vertx.core.Handler) method is invoked.

The consumer is unregistered from the event bus using the unregister() method or by calling the handler(io.vertx.core.Handler) with a null value..

Author
Nick Scavelli

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

The address the handler was registered with.
address
()

public ReadStream<T>

Returns:

a read stream for the body of the message stream.
bodyStream
()

public void
completionHandler(Handler<AsyncResult<Void>>
the completion handler
completionHandler
)

Optional method which can be called to indicate when the registration has been propagated across the cluster.

public MessageConsumer<T>
endHandler(Handler<Void> endHandler)

public MessageConsumer<T>
public MessageConsumer<T>
fetch(long amount)

Redeclares io.vertx.core.streams.ReadStream.fetch.

Fetch the specified amount of elements.

public int

Returns:

the maximum number of messages that can be buffered when this stream is paused
getMaxBufferedMessages
()

public MessageConsumer<T>
handler(Handler<Message<T>> handler)

public boolean

Returns:

true if the current consumer is registered
isRegistered
()

public MessageConsumer<T>
pause()

Redeclares io.vertx.core.streams.ReadStream.pause.

Pause the ReadStream, it sets the buffer in fetch mode and clears the actual demand.

public MessageConsumer<T>
resume()

Redeclares io.vertx.core.streams.ReadStream.resume.

Resume reading, and sets the buffer in flowing mode.

public MessageConsumer<T>

Returns:

this registration
setMaxBufferedMessages
(int
the maximum number of messages that can be buffered
maxBufferedMessages
)
Deprecated for removal, instead use MessageConsumerOptions#setMaxBufferedMessages(int)

Set the number of messages this registration will buffer when this stream is paused.

public Future<Void>
unregister()

Unregisters the handler which created this registration

public void
unregister(Handler<AsyncResult<Void>>
the handler called when the unregister is done. For example in a cluster when all nodes of the event bus have been unregistered.
completionHandler
)

Unregisters the handler which created this registration

Inherited from io.vertx.core.streams.ReadStream:
collectendHandlerexceptionHandlerhandlerpipepipeTopipeTo

Method Detail

addressback to summary
public String address()
Returns:String

The address the handler was registered with.

bodyStreamback to summary
public ReadStream<T> bodyStream()
Returns:ReadStream<T>

a read stream for the body of the message stream.

completionHandlerback to summary
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:Handler<AsyncResult<Void>>

the completion handler

endHandlerback to summary
public MessageConsumer<T> endHandler(Handler<Void> endHandler)
Annotations
@Override
exceptionHandlerback to summary
public MessageConsumer<T> exceptionHandler(Handler<Throwable> handler)
Annotations
@Override
fetchback to summary
public MessageConsumer<T> fetch(long amount)

Redeclares io.vertx.core.streams.ReadStream.fetch.

Doc from io.vertx.core.streams.ReadStream.fetch.

Fetch the specified amount of elements. If the ReadStream has been paused, reading will recommence with the specified amount of items, otherwise the specified amount will be added to the current stream demand.

Returns:MessageConsumer<T>

a reference to this, so the API can be used fluently

Annotations
@Override
getMaxBufferedMessagesback to summary
public int getMaxBufferedMessages()
Returns:int

the maximum number of messages that can be buffered when this stream is paused

handlerback to summary
public MessageConsumer<T> handler(Handler<Message<T>> handler)
Annotations
@Override
isRegisteredback to summary
public boolean isRegistered()
Returns:boolean

true if the current consumer is registered

pauseback to summary
public MessageConsumer<T> pause()

Redeclares io.vertx.core.streams.ReadStream.pause.

Doc from io.vertx.core.streams.ReadStream.pause.

Pause the ReadStream, it sets the buffer in fetch mode and clears the actual demand.

While it's paused, no data will be sent to the data handler.

Returns:MessageConsumer<T>

a reference to this, so the API can be used fluently

Annotations
@Override
resumeback to summary
public MessageConsumer<T> resume()

Redeclares io.vertx.core.streams.ReadStream.resume.

Doc from io.vertx.core.streams.ReadStream.resume.

Resume reading, and sets the buffer in flowing mode.

If the ReadStream has been paused, reading will recommence on it.

Returns:MessageConsumer<T>

a reference to this, so the API can be used fluently

Annotations
@Override
setMaxBufferedMessagesback to summary
public MessageConsumer<T> setMaxBufferedMessages(int maxBufferedMessages)

Deprecated

for removal, instead use MessageConsumerOptions#setMaxBufferedMessages(int)

Set the number of messages this registration will buffer when this stream is paused. The default value is 1000.

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:int

the maximum number of messages that can be buffered

Returns:MessageConsumer<T>

this registration

Annotations
@Deprecated
unregisterback to summary
public Future<Void> unregister()

Unregisters the handler which created this registration

unregisterback to summary
public void unregister(Handler<AsyncResult<Void>> completionHandler)

Unregisters the handler which created this registration

Parameters
completionHandler:Handler<AsyncResult<Void>>

the handler called when the unregister is done. For example in a cluster when all nodes of the event bus have been unregistered.