Package io.vertx.rabbitmq
Interface RabbitMQConsumer
-
- All Superinterfaces:
ReadStream<RabbitMQMessage>,StreamBase
public interface RabbitMQConsumer extends ReadStream<RabbitMQMessage>
A stream of messages from a rabbitmq queue.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Future<Void>cancel()Stop message consumption from a queue.StringconsumerTag()RabbitMQConsumerendHandler(Handler<Void> endHandler)Set an end handler.RabbitMQConsumerexceptionHandler(Handler<Throwable> exceptionHandler)Set an exception handler on the read stream.RabbitMQConsumerfetch(long amount)Fetch the specifiedamountof elements.RabbitMQConsumerhandler(Handler<RabbitMQMessage> messageArrived)Set a message handler.booleanisCancelled()Returntrueif cancel() has been called.booleanisPaused()RabbitMQConsumerpause()Pause the stream of incoming messages from queue.StringqueueName()RabbitMQConsumerresume()Resume reading from a queue.RabbitMQConsumersetQueueName(String name)Set the name of the queue.-
Methods inherited from interface io.vertx.core.streams.ReadStream
blockingStream, collect, pipe, pipeTo
-
-
-
-
Method Detail
-
exceptionHandler
RabbitMQConsumer exceptionHandler(Handler<Throwable> exceptionHandler)
Set an exception handler on the read stream.- Specified by:
exceptionHandlerin interfaceReadStream<RabbitMQMessage>- Specified by:
exceptionHandlerin interfaceStreamBase- Parameters:
exceptionHandler- the exception handler- Returns:
- a reference to this, so the API can be used fluently
-
handler
RabbitMQConsumer handler(Handler<RabbitMQMessage> messageArrived)
Set a message handler. As message appear in a queue, the handler will be called with the message.- Specified by:
handlerin interfaceReadStream<RabbitMQMessage>- Returns:
- a reference to this, so the API can be used fluently
-
pause
RabbitMQConsumer pause()
Pause the stream of incoming messages from queue.The messages will continue to arrive, but they will be stored in a internal queue. If the queue size would exceed the limit provided by
RabbitMQConsumer#size(int), then incoming messages will be discarded.- Specified by:
pausein interfaceReadStream<RabbitMQMessage>- Returns:
- a reference to this, so the API can be used fluently
-
resume
RabbitMQConsumer resume()
Resume reading from a queue. Flushes internal queue.- Specified by:
resumein interfaceReadStream<RabbitMQMessage>- Returns:
- a reference to this, so the API can be used fluently
-
endHandler
RabbitMQConsumer endHandler(Handler<Void> endHandler)
Set an end handler. Once the stream has canceled successfully, the handler will be called.- Specified by:
endHandlerin interfaceReadStream<RabbitMQMessage>- Returns:
- a reference to this, so the API can be used fluently
-
queueName
String queueName()
- Returns:
- the name of the queue
-
setQueueName
RabbitMQConsumer setQueueName(String name)
Set the name of the queue. This method is typically only required during a connectionEstablishedCallback when the queue name has changed.- Parameters:
name- the name of the queue- Returns:
- a reference to this, so the API can be used fluently
-
consumerTag
String consumerTag()
- Returns:
- a consumer tag
-
cancel
Future<Void> cancel()
Stop message consumption from a queue.The operation is asynchronous. When consumption is stopped, you can also be notified via
endHandler(Handler)- Returns:
- a future through which you can find out the operation status.
-
isCancelled
boolean isCancelled()
Returntrueif cancel() has been called.- Returns:
trueif cancel() has been called.
-
isPaused
boolean isPaused()
- Returns:
- is the stream paused?
-
fetch
RabbitMQConsumer fetch(long amount)
Fetch 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<RabbitMQMessage>- Returns:
- a reference to this, so the API can be used fluently
-
-