package io.vertx.rabbitmq;

import io.vertx.codegen.annotations.Fluent;
import io.vertx.codegen.annotations.VertxGen;
import io.vertx.core.AsyncResult;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.streams.ReadStream;

A stream of messages from a rabbitmq queue.
/** * A stream of messages from a rabbitmq queue. */
@VertxGen public interface RabbitMQConsumer extends ReadStream<RabbitMQMessage> {
Set an exception handler on the read stream.
Params:
  • exceptionHandler – the exception handler
Returns:a reference to this, so the API can be used fluently
/** * Set an exception handler on the read stream. * * @param exceptionHandler the exception handler * @return a reference to this, so the API can be used fluently */
@Override RabbitMQConsumer exceptionHandler(Handler<Throwable> exceptionHandler);
Set a message handler. As message appear in a queue, the handler will be called with the message.
Returns:a reference to this, so the API can be used fluently
/** * Set a message handler. As message appear in a queue, the handler will be called with the message. * * @return a reference to this, so the API can be used fluently */
@Override RabbitMQConsumer handler(Handler<RabbitMQMessage> messageArrived);
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 size(int), then incoming messages will be discarded.

Returns:a reference to this, so the API can be used fluently
/** * Pause the stream of incoming messages from queue. * <p> * 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 {@link RabbitMQConsumer#size(int)}, then incoming messages will be discarded. * * @return a reference to this, so the API can be used fluently */
@Override RabbitMQConsumer pause();
Resume reading from a queue. Flushes internal queue.
Returns:a reference to this, so the API can be used fluently
/** * Resume reading from a queue. Flushes internal queue. * * @return a reference to this, so the API can be used fluently */
@Override RabbitMQConsumer resume();
Set an end handler. Once the stream has canceled successfully, the handler will be called.
Returns:a reference to this, so the API can be used fluently
/** * Set an end handler. Once the stream has canceled successfully, the handler will be called. * * @return a reference to this, so the API can be used fluently */
@Override RabbitMQConsumer endHandler(Handler<Void> endHandler);
Returns:the name of the queue
/** * @return the name of the queue */
String queueName();
Set the name of the queue. This method is typically only required during a connectionEstablishedCallback when the queue name has changed.
Params:
  • name – the name of the queue
Returns:a reference to this, so the API can be used fluently
/** * Set the name of the queue. * This method is typically only required during a connectionEstablishedCallback when the queue name has changed. * @param name the name of the queue * @return a reference to this, so the API can be used fluently */
@Fluent RabbitMQConsumer setQueueName(String name);
Returns:a consumer tag
/** * @return a consumer tag */
String consumerTag();
Stop message consumption from a queue.

The operation is asynchronous. When consumption is stopped, you can also be notified via endHandler(Handler<Void>)

Returns:a future through which you can find out the operation status.
/** * Stop message consumption from a queue. * <p> * The operation is asynchronous. When consumption is stopped, you can also be notified via {@link RabbitMQConsumer#endHandler(Handler)} * * @return a future through which you can find out the operation status. */
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<Void>)

Params:
  • cancelResult – contains information about operation status: success/fail.
/** * Stop message consumption from a queue. * <p> * The operation is asynchronous. When consumption is stopped, you can also be notified via {@link RabbitMQConsumer#endHandler(Handler)} * * @param cancelResult contains information about operation status: success/fail. */
void cancel(Handler<AsyncResult<Void>> cancelResult);
Return true if cancel() has been called.
Returns:true if cancel() has been called.
/** * Return {@code true} if cancel() has been called. * @return {@code true} if cancel() has been called. */
boolean isCancelled();
Returns:is the stream paused?
/** * @return is the stream paused? */
boolean isPaused();
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:a reference to this, so the API can be used fluently
/** * Fetch the specified {@code amount} of elements. If the {@code ReadStream} has been paused, reading will * recommence with the specified {@code amount} of items, otherwise the specified {@code amount} will * be added to the current stream demand. * * @return a reference to this, so the API can be used fluently */
RabbitMQConsumer fetch(long amount); }