org.apache.qpid.server
Class AMQChannel

java.lang.Object
  extended by org.apache.qpid.server.AMQChannel

public class AMQChannel
extends java.lang.Object


Field Summary
static int DEFAULT_PREFETCH
           
 
Constructor Summary
AMQChannel(int channelId, MessageStore messageStore, MessageRouter exchanges)
           
 
Method Summary
 void acknowledgeMessage(long deliveryTag, boolean multiple)
          Acknowledge one or more messages.
 void addUnacknowledgedMessage(AMQMessage message, long deliveryTag, java.lang.String consumerTag, AMQQueue queue)
          Add a message to the channel-based list of unacknowledged messages
 void close(AMQProtocolSession session)
          Called from the protocol session to close this channel and clean up.
 void commit()
           
 int getChannelId()
           
 AMQQueue getDefaultQueue()
           
 int getNextConsumerTag()
           
 long getNextDeliveryTag()
           
 long getPrefetchCount()
           
 long getPrefetchHighMarkCount()
           
 long getPrefetchLowMarkCount()
           
 java.util.Map<java.lang.Long,UnacknowledgedMessage> getUnacknowledgedMessageMap()
          Used only for testing purposes.
 boolean isSuspended()
           
 boolean isTransactional()
           
 void processReturns(AMQProtocolSession session)
           
 void publishContentBody(org.apache.qpid.framing.ContentBody contentBody)
           
 void publishContentHeader(org.apache.qpid.framing.ContentHeaderBody contentHeaderBody)
           
 void queueDeleted(AMQQueue queue)
          Callback indicating that a queue has been deleted.
 void requeue()
          Called to attempt re-enqueue all outstanding unacknowledged messages on the channel.
 void resend(AMQProtocolSession session)
          Called to resend all outstanding unacknowledged messages to this same channel.
 void rollback()
           
protected  void routeCurrentMessage()
           
 void setDefaultQueue(AMQQueue queue)
           
 void setPrefetchCount(long prefetchCount)
           
 void setPrefetchHighMarkCount(long prefetchCount)
           
 void setPrefetchLowMarkCount(long prefetchCount)
           
 void setPublishFrame(org.apache.qpid.framing.BasicPublishBody publishBody, AMQProtocolSession publisher)
           
 void setSuspended(boolean suspended)
           
 void setTransactional(boolean transactional)
           
 java.lang.String subscribeToQueue(java.lang.String tag, AMQQueue queue, AMQProtocolSession session, boolean acks)
          Subscribe to a queue.
 java.lang.String toString()
           
 void unsubscribeConsumer(AMQProtocolSession session, java.lang.String consumerTag)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_PREFETCH

public static final int DEFAULT_PREFETCH
See Also:
Constant Field Values
Constructor Detail

AMQChannel

public AMQChannel(int channelId,
                  MessageStore messageStore,
                  MessageRouter exchanges)
           throws org.apache.qpid.AMQException
Throws:
org.apache.qpid.AMQException
Method Detail

getChannelId

public int getChannelId()

isTransactional

public boolean isTransactional()

setTransactional

public void setTransactional(boolean transactional)

getPrefetchCount

public long getPrefetchCount()

setPrefetchCount

public void setPrefetchCount(long prefetchCount)

getPrefetchLowMarkCount

public long getPrefetchLowMarkCount()

setPrefetchLowMarkCount

public void setPrefetchLowMarkCount(long prefetchCount)

getPrefetchHighMarkCount

public long getPrefetchHighMarkCount()

setPrefetchHighMarkCount

public void setPrefetchHighMarkCount(long prefetchCount)

setPublishFrame

public void setPublishFrame(org.apache.qpid.framing.BasicPublishBody publishBody,
                            AMQProtocolSession publisher)
                     throws org.apache.qpid.AMQException
Throws:
org.apache.qpid.AMQException

publishContentHeader

public void publishContentHeader(org.apache.qpid.framing.ContentHeaderBody contentHeaderBody)
                          throws org.apache.qpid.AMQException
Throws:
org.apache.qpid.AMQException

publishContentBody

public void publishContentBody(org.apache.qpid.framing.ContentBody contentBody)
                        throws org.apache.qpid.AMQException
Throws:
org.apache.qpid.AMQException

routeCurrentMessage

protected void routeCurrentMessage()
                            throws org.apache.qpid.AMQException
Throws:
org.apache.qpid.AMQException

getNextDeliveryTag

public long getNextDeliveryTag()

getNextConsumerTag

public int getNextConsumerTag()

subscribeToQueue

public java.lang.String subscribeToQueue(java.lang.String tag,
                                         AMQQueue queue,
                                         AMQProtocolSession session,
                                         boolean acks)
                                  throws org.apache.qpid.AMQException,
                                         ConsumerTagNotUniqueException
Subscribe to a queue. We register all subscriptions in the channel so that if the channel is closed we can clean up all subscriptions, even if the client does not explicitly unsubscribe from all queues.

Parameters:
tag - the tag chosen by the client (if null, server will generate one)
queue - the queue to subscribe to
session - the protocol session of the subscriber
Returns:
the consumer tag. This is returned to the subscriber and used in subsequent unsubscribe requests
Throws:
ConsumerTagNotUniqueException - if the tag is not unique
org.apache.qpid.AMQException - if something goes wrong

unsubscribeConsumer

public void unsubscribeConsumer(AMQProtocolSession session,
                                java.lang.String consumerTag)
                         throws org.apache.qpid.AMQException
Throws:
org.apache.qpid.AMQException

close

public void close(AMQProtocolSession session)
           throws org.apache.qpid.AMQException
Called from the protocol session to close this channel and clean up.

Throws:
org.apache.qpid.AMQException - if there is an error during closure

addUnacknowledgedMessage

public void addUnacknowledgedMessage(AMQMessage message,
                                     long deliveryTag,
                                     java.lang.String consumerTag,
                                     AMQQueue queue)
Add a message to the channel-based list of unacknowledged messages

Parameters:
message -
deliveryTag -
queue -

requeue

public void requeue()
             throws org.apache.qpid.AMQException
Called to attempt re-enqueue all outstanding unacknowledged messages on the channel. May result in delivery to this same channel or to other subscribers.

Throws:
org.apache.qpid.AMQException

resend

public void resend(AMQProtocolSession session)
Called to resend all outstanding unacknowledged messages to this same channel.


queueDeleted

public void queueDeleted(AMQQueue queue)
Callback indicating that a queue has been deleted. We must update the structure of unacknowledged messages to remove the queue reference and also decrement any message reference counts, without actually removing the item sine we may get an ack for a delivery tag that was generated from the deleted queue.

Parameters:
queue -

acknowledgeMessage

public void acknowledgeMessage(long deliveryTag,
                               boolean multiple)
                        throws org.apache.qpid.AMQException
Acknowledge one or more messages.

Parameters:
deliveryTag - the last delivery tag
multiple - if true will acknowledge all messages up to an including the delivery tag. if false only acknowledges the single message specified by the delivery tag
Throws:
org.apache.qpid.AMQException - if the delivery tag is unknown (e.g. not outstanding) on this channel

getUnacknowledgedMessageMap

public java.util.Map<java.lang.Long,UnacknowledgedMessage> getUnacknowledgedMessageMap()
Used only for testing purposes.

Returns:
the map of unacknowledged messages

setSuspended

public void setSuspended(boolean suspended)

isSuspended

public boolean isSuspended()

commit

public void commit()
            throws org.apache.qpid.AMQException
Throws:
org.apache.qpid.AMQException

rollback

public void rollback()
              throws org.apache.qpid.AMQException
Throws:
org.apache.qpid.AMQException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setDefaultQueue

public void setDefaultQueue(AMQQueue queue)

getDefaultQueue

public AMQQueue getDefaultQueue()

processReturns

public void processReturns(AMQProtocolSession session)