Interface RabbitMQConsumer
- All Superinterfaces:
ReadStream<RabbitMQMessage>, StreamBase
A stream of messages from a rabbitmq queue.
-
Method Summary
Modifier and TypeMethodDescriptioncancel()Stop message consumption from a queue.endHandler(Handler<Void> endHandler) Set an end handler.exceptionHandler(Handler<Throwable> exceptionHandler) Set an exception handler on the read stream.fetch(long amount) Fetch the specifiedamountof elements.handler(Handler<RabbitMQMessage> messageArrived) Set a message handler.booleanReturntrueif cancel() has been called.booleanisPaused()pause()Pause the stream of incoming messages from queue.resume()Resume reading from a queue.setQueueName(String name) Set the name of the queue.Methods inherited from interface ReadStream
blockingStream, collect, pipe, pipeTo
-
Method Details
-
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
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
, then incoming messages will be discarded.invalid reference
RabbitMQConsumer#size(int)- 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
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
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
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
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
-