Package com.rabbitmq.client
Class RpcServer.DefaultRpcConsumer
- java.lang.Object
-
- com.rabbitmq.client.DefaultConsumer
-
- com.rabbitmq.client.RpcServer.DefaultRpcConsumer
-
- All Implemented Interfaces:
Consumer
,RpcServer.RpcConsumer
- Enclosing class:
- RpcServer
private static class RpcServer.DefaultRpcConsumer extends DefaultConsumer implements RpcServer.RpcConsumer
-
-
Field Summary
Fields Modifier and Type Field Description private ConsumerCancelledException
_cancelled
private java.util.concurrent.BlockingQueue<Delivery>
_queue
private ShutdownSignalException
_shutdown
private static Delivery
POISON
-
Constructor Summary
Constructors Constructor Description DefaultRpcConsumer(Channel ch)
DefaultRpcConsumer(Channel ch, java.util.concurrent.BlockingQueue<Delivery> q)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
checkShutdown()
Check if we are in shutdown mode and if so throw an exception.private Delivery
handle(Delivery delivery)
If delivery is not POISON nor null, return it.void
handleCancel(java.lang.String consumerTag)
No-op implementation ofConsumer.handleCancel(String)
void
handleDelivery(java.lang.String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body)
void
handleShutdownSignal(java.lang.String consumerTag, ShutdownSignalException sig)
No-op implementation ofConsumer.handleShutdownSignal(java.lang.String, com.rabbitmq.client.ShutdownSignalException)
.Delivery
nextDelivery()
-
Methods inherited from class com.rabbitmq.client.DefaultConsumer
getChannel, getConsumerTag, handleCancelOk, handleConsumeOk, handleRecoverOk
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.rabbitmq.client.Consumer
handleCancelOk, handleConsumeOk, handleRecoverOk
-
Methods inherited from interface com.rabbitmq.client.RpcServer.RpcConsumer
getConsumerTag
-
-
-
-
Field Detail
-
POISON
private static final Delivery POISON
-
_queue
private final java.util.concurrent.BlockingQueue<Delivery> _queue
-
_shutdown
private volatile ShutdownSignalException _shutdown
-
_cancelled
private volatile ConsumerCancelledException _cancelled
-
-
Method Detail
-
nextDelivery
public Delivery nextDelivery() throws java.lang.InterruptedException, ShutdownSignalException, ConsumerCancelledException
- Specified by:
nextDelivery
in interfaceRpcServer.RpcConsumer
- Throws:
java.lang.InterruptedException
ShutdownSignalException
ConsumerCancelledException
-
handleShutdownSignal
public void handleShutdownSignal(java.lang.String consumerTag, ShutdownSignalException sig)
Description copied from class:DefaultConsumer
No-op implementation ofConsumer.handleShutdownSignal(java.lang.String, com.rabbitmq.client.ShutdownSignalException)
.- Specified by:
handleShutdownSignal
in interfaceConsumer
- Overrides:
handleShutdownSignal
in classDefaultConsumer
- Parameters:
consumerTag
- the consumer tag associated with the consumersig
- aShutdownSignalException
indicating the reason for the shut down
-
handleCancel
public void handleCancel(java.lang.String consumerTag) throws java.io.IOException
Description copied from class:DefaultConsumer
No-op implementation ofConsumer.handleCancel(String)
- Specified by:
handleCancel
in interfaceConsumer
- Overrides:
handleCancel
in classDefaultConsumer
- Parameters:
consumerTag
- the defined consumer tag (client- or server-generated)- Throws:
java.io.IOException
-
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 ofConsumer.handleDelivery(java.lang.String, com.rabbitmq.client.Envelope, com.rabbitmq.client.AMQP.BasicProperties, byte[])
.- Specified by:
handleDelivery
in interfaceConsumer
- Overrides:
handleDelivery
in classDefaultConsumer
- 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:
java.io.IOException
- if the consumer encounters an I/O error while processing the message- See Also:
Envelope
-
checkShutdown
private void checkShutdown()
Check if we are in shutdown mode and if so throw an exception.
-
handle
private Delivery handle(Delivery delivery)
If delivery is not POISON nor null, return it. If delivery, _shutdown and _cancelled are all null, return null. If delivery is POISON re-insert POISON into the queue and throw an exception if POISONed for no reason. Otherwise, if we are in shutdown mode or cancelled, throw a corresponding exception.
-
-