com.rabbitmq.client
Interface Consumer

All Known Implementing Classes:
DefaultConsumer, QueueingConsumer

public interface Consumer

Interface for application callback objects to receive notifications and messages from a queue by subscription. Most consumers will subclass DefaultConsumer. Note: all methods of this interface are invoked inside the Connection's thread. This means they a) should be non-blocking and generally do little work, b) must not call Channel or Connection methods, or a deadlock will ensue. One way of ensuring this is to use/subclass QueueingConsumer.

See Also:
Channel.basicConsume(java.lang.String, com.rabbitmq.client.Consumer), Channel.basicCancel(java.lang.String)

Method Summary
 void handleCancelOk(java.lang.String consumerTag)
          Called when the consumer is deregistered by a call to Channel.basicCancel(java.lang.String).
 void handleConsumeOk(java.lang.String consumerTag)
          Called when the consumer is first registered by a call to Channel.basicConsume(java.lang.String, com.rabbitmq.client.Consumer).
 void handleDelivery(java.lang.String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body)
          Called when a delivery appears for this consumer.
 void handleRecoverOk()
          Called to notify the consumer that we've received a basic.recover-ok in reply to a basic.recover some other thread sent.
 void handleShutdownSignal(java.lang.String consumerTag, ShutdownSignalException sig)
          Called to the consumer that either the channel or the undelying connection has been shut down.
 

Method Detail

handleConsumeOk

void handleConsumeOk(java.lang.String consumerTag)
Called when the consumer is first registered by a call to Channel.basicConsume(java.lang.String, com.rabbitmq.client.Consumer). Note: if the consumer was registered with an empty string for its consumerTag, the server will have autogenerated and replied with a fresh consumerTag.

Parameters:
consumerTag - the defined consumerTag (either client- or server-generated)

handleCancelOk

void handleCancelOk(java.lang.String consumerTag)
Called when the consumer is deregistered by a call to Channel.basicCancel(java.lang.String).

Parameters:
consumerTag - the defined consumerTag (either client- or server-generated)

handleShutdownSignal

void handleShutdownSignal(java.lang.String consumerTag,
                          ShutdownSignalException sig)
Called to the consumer that either the channel or the undelying connection has been shut down.

Parameters:
consumerTag - the defined consumerTag (either client- or server-generated)
sig - an exception object encapsulating the reason for shutdown

handleRecoverOk

void handleRecoverOk()
Called to notify the consumer that we've received a basic.recover-ok in reply to a basic.recover some other thread sent. All messages received before this is invoked that haven't been ack'ed will be redelivered. All messages received afterwards won't be. This method exists since all the Consumer callbacks are invoked by the connection main loop thread - so it's sometimes useful to allow that thread to know that the recover-ok has been received, rather than the thread which invoked basicRecover().


handleDelivery

void handleDelivery(java.lang.String consumerTag,
                    Envelope envelope,
                    AMQP.BasicProperties properties,
                    byte[] body)
                    throws java.io.IOException
Called when a delivery appears for this consumer.

Parameters:
consumerTag - the defined consumerTag (either client- or server-generated)
envelope - packaging data for the message
properties - content header data for the message
body - the message body (opaque client-specific byte array)
Throws:
java.io.IOException - if the consumer hits an I/O error while processing the message