Package com.rabbitmq.client
Interface Consumer
-
- All Known Implementing Classes:
DefaultConsumer,QueueingConsumer
public interface ConsumerInterface for application callback objects to receive notifications and messages from a queue by subscription. Most implementations will subclass
DefaultConsumer.The methods of this interface are invoked in a dispatch thread which is separate from the
TheConnection's thread. This allowsConsumers to callChannelorConnectionmethods without causing a deadlock.Consumers on a particularChannelare invoked serially on one or more dispatch threads.Consumers should avoid executing long-running code because this will delay dispatch of messages to otherConsumers on the sameChannel.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidhandleCancel(String consumerTag)Called when the consumer is cancelled for reasons other than by a call toChannel.basicCancel(java.lang.String).voidhandleCancelOk(String consumerTag)Called when the consumer is cancelled by a call toChannel.basicCancel(java.lang.String).voidhandleConsumeOk(String consumerTag)Called when the consumer is registered by a call to any of theChannel.basicConsume(java.lang.String, com.rabbitmq.client.Consumer)methods.voidhandleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body)Called when abasic.deliveris received for this consumer.voidhandleRecoverOk(String consumerTag)Called when abasic.recover-okis received in reply to abasic.recover.voidhandleShutdownSignal(String consumerTag, ShutdownSignalException sig)Called when either the channel or the underlying connection has been shut down.
-
-
-
Method Detail
-
handleConsumeOk
void handleConsumeOk(String consumerTag)
Called when the consumer is registered by a call to any of theChannel.basicConsume(java.lang.String, com.rabbitmq.client.Consumer)methods.- Parameters:
consumerTag- the consumer tag associated with the consumer
-
handleCancelOk
void handleCancelOk(String consumerTag)
Called when the consumer is cancelled by a call toChannel.basicCancel(java.lang.String).- Parameters:
consumerTag- the consumer tag associated with the consumer
-
handleCancel
void handleCancel(String consumerTag) throws IOException
Called when the consumer is cancelled for reasons other than by a call toChannel.basicCancel(java.lang.String). For example, the queue has been deleted. SeehandleCancelOk(java.lang.String)for notification of consumer cancellation due toChannel.basicCancel(java.lang.String).- Parameters:
consumerTag- the consumer tag associated with the consumer- Throws:
IOException
-
handleShutdownSignal
void handleShutdownSignal(String consumerTag, ShutdownSignalException sig)
Called when either the channel or the underlying connection has been shut down.- Parameters:
consumerTag- the consumer tag associated with the consumersig- aShutdownSignalExceptionindicating the reason for the shut down
-
handleRecoverOk
void handleRecoverOk(String consumerTag)
Called when abasic.recover-okis received in reply to abasic.recover. All messages received before this is invoked that haven't been ack'ed will be re-delivered. All messages received afterwards won't be.- Parameters:
consumerTag- the consumer tag associated with the consumer
-
handleDelivery
void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException
Called when abasic.deliveris received for this consumer.- Parameters:
consumerTag- the consumer tag associated with the consumerenvelope- packaging data for the messageproperties- content header data for the messagebody- the message body (opaque, client-specific byte array)- Throws:
IOException- if the consumer encounters an I/O error while processing the message- See Also:
Envelope
-
-