com.rabbitmq.client
Class QueueingConsumer

java.lang.Object
  extended by com.rabbitmq.client.DefaultConsumer
      extended by com.rabbitmq.client.QueueingConsumer
All Implemented Interfaces:
Consumer

public class QueueingConsumer
extends DefaultConsumer

Convenience class: an implementation of Consumer with straightforward blocking semantics


Nested Class Summary
static class QueueingConsumer.Delivery
          Encapsulates an arbitrary message - simple "bean" holder structure.
 
Constructor Summary
QueueingConsumer(Channel ch)
           
QueueingConsumer(Channel ch, java.util.concurrent.BlockingQueue<QueueingConsumer.Delivery> q)
           
 
Method Summary
 void handleDelivery(java.lang.String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body)
          No-op implementation of Consumer.handleDelivery(java.lang.String, com.rabbitmq.client.Envelope, com.rabbitmq.client.AMQP.BasicProperties, byte[]).
 void handleShutdownSignal(java.lang.String consumerTag, ShutdownSignalException sig)
          No-op implementation of Consumer.handleShutdownSignal(java.lang.String, com.rabbitmq.client.ShutdownSignalException).
 QueueingConsumer.Delivery nextDelivery()
          Main application-side API: wait for the next message delivery and return it.
 QueueingConsumer.Delivery nextDelivery(long timeout)
          Main application-side API: wait for the next message delivery and return it.
 
Methods inherited from class com.rabbitmq.client.DefaultConsumer
getChannel, getConsumerTag, handleCancelOk, handleConsumeOk
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueueingConsumer

public QueueingConsumer(Channel ch)

QueueingConsumer

public QueueingConsumer(Channel ch,
                        java.util.concurrent.BlockingQueue<QueueingConsumer.Delivery> q)
Method Detail

handleShutdownSignal

public void handleShutdownSignal(java.lang.String consumerTag,
                                 ShutdownSignalException sig)
Description copied from class: DefaultConsumer
No-op implementation of Consumer.handleShutdownSignal(java.lang.String, com.rabbitmq.client.ShutdownSignalException).

Specified by:
handleShutdownSignal in interface Consumer
Overrides:
handleShutdownSignal in class DefaultConsumer
Parameters:
consumerTag - the defined consumerTag (either client- or server-generated)
sig - an exception object encapsulating the reason for shutdown

handleDelivery

public void handleDelivery(java.lang.String consumerTag,
                           Envelope envelope,
                           AMQP.BasicProperties properties,
                           byte[] body)
                    throws java.io.IOException
Description copied from class: DefaultConsumer
No-op implementation of Consumer.handleDelivery(java.lang.String, com.rabbitmq.client.Envelope, com.rabbitmq.client.AMQP.BasicProperties, byte[]).

Specified by:
handleDelivery in interface Consumer
Overrides:
handleDelivery in class DefaultConsumer
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

nextDelivery

public QueueingConsumer.Delivery nextDelivery()
                                       throws java.lang.InterruptedException,
                                              ShutdownSignalException
Main application-side API: wait for the next message delivery and return it.

Returns:
the next message
Throws:
java.lang.InterruptedException - if an interrupt is received while waiting
ShutdownSignalException - if the connection is shut down while waiting

nextDelivery

public QueueingConsumer.Delivery nextDelivery(long timeout)
                                       throws java.lang.InterruptedException,
                                              ShutdownSignalException
Main application-side API: wait for the next message delivery and return it.

Parameters:
timeout - timeout in millisecond
Returns:
the next message or null if timed out
Throws:
java.lang.InterruptedException - if an interrupt is received while waiting
ShutdownSignalException - if the connection is shut down while waiting