org.apache.qpid.server
Class AMQChannel

java.lang.Object
  extended by org.apache.qpid.server.AMQChannel
All Implemented Interfaces:
ConfiguredObject<SessionConfigType,SessionConfig>, SessionConfig, AMQSessionModel

public class AMQChannel
extends Object
implements SessionConfig, AMQSessionModel


Field Summary
protected  Map<org.apache.qpid.framing.AMQShortString,Subscription> _tag2SubscriptionMap
          Maps from consumer tag to subscription instance.
static int DEFAULT_PREFETCH
           
 
Constructor Summary
AMQChannel(AMQProtocolSession session, int channelId, MessageStore messageStore)
           
 
Method Summary
 void acknowledgeMessage(long deliveryTag, boolean multiple)
          Acknowledge one or more messages.
 void addUnacknowledgedMessage(QueueEntry entry, long deliveryTag, Subscription subscription)
          Add a message to the channel-based list of unacknowledged messages
 void block(AMQQueue queue)
           
 void close()
          Called from the protocol session to close this channel and clean up.
 void commit()
           
 String debugIdentity()
           
 boolean getBlocking()
           
 int getChannel()
           
 int getChannelId()
           
 ClientDeliveryMethod getClientDeliveryMethod()
           
 String getClientID()
           
 ConfigStore getConfigStore()
           
 SessionConfigType getConfigType()
           
 ConnectionConfig getConnectionConfig()
           
 AMQConnectionModel getConnectionModel()
           
 long getCreateTime()
           
 FlowCreditManager getCreditManager()
           
 AMQQueue getDefaultQueue()
           
 long getDetachedLifespan()
           
 Long getExpiryTime()
           
 UUID getId()
           
 Object getID()
           
 LogActor getLogActor()
           
 LogSubject getLogSubject()
           
 Long getMaxClientRate()
           
 MessageStore getMessageStore()
           
 int getNextConsumerTag()
           
 long getNextDeliveryTag()
           
 ConfiguredObject getParent()
           
 AMQProtocolSession getProtocolSession()
           
 RecordDeliveryMethod getRecordDeliveryMethod()
           
 String getSessionName()
           
 Subscription getSubscription(org.apache.qpid.framing.AMQShortString subscription)
           
 Long getTxnCommits()
           
 Long getTxnCount()
           
 Long getTxnRejects()
           
 Long getTxnStarts()
           
 UnacknowledgedMessageMap getUnacknowledgedMessageMap()
          Used only for testing purposes.
 VirtualHost getVirtualHost()
           
 boolean isAttached()
           
 boolean isClosing()
           
 boolean isDurable()
           
 boolean isSuspended()
           
 boolean isTransactional()
           
 void mgmtClose()
           
 void publishContentBody(org.apache.qpid.framing.ContentBody contentBody)
           
 void publishContentHeader(org.apache.qpid.framing.ContentHeaderBody contentHeaderBody)
           
 void requeue()
          Called to attempt re-delivery all outstanding unacknowledged messages on the channel.
 void requeue(long deliveryTag)
          Requeue a single message
 void resend(boolean requeue)
          Called to resend all outstanding unacknowledged messages to this same channel.
 void rollback()
           
 void rollback(Runnable postRollbackTask)
           
protected  void routeCurrentMessage()
           
 void setCredit(long prefetchSize, int prefetchCount)
           
 void setDefaultQueue(AMQQueue queue)
           
 void setLocalTransactional()
          Sets this channel to be part of a local transaction
 void setPublishFrame(org.apache.qpid.framing.abstraction.MessagePublishInfo info, Exchange e)
           
 void setSuspended(boolean suspended)
          Called from the ChannelFlowHandler to suspend this Channel
 org.apache.qpid.framing.AMQShortString subscribeToQueue(org.apache.qpid.framing.AMQShortString tag, AMQQueue queue, boolean acks, org.apache.qpid.framing.FieldTable filters, boolean noLocal, boolean exclusive)
          Subscribe to a queue.
 String toString()
           
 void unblock(AMQQueue queue)
           
 boolean unsubscribeConsumer(org.apache.qpid.framing.AMQShortString consumerTag)
          Unsubscribe a consumer from a queue.
 
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

_tag2SubscriptionMap

protected final Map<org.apache.qpid.framing.AMQShortString,Subscription> _tag2SubscriptionMap
Maps from consumer tag to subscription instance. Allows us to unsubscribe from a queue.

Constructor Detail

AMQChannel

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

getConfigStore

public ConfigStore getConfigStore()

setLocalTransactional

public void setLocalTransactional()
Sets this channel to be part of a local transaction


isTransactional

public boolean isTransactional()
Specified by:
isTransactional in interface SessionConfig

getTxnStarts

public Long getTxnStarts()
Specified by:
getTxnStarts in interface SessionConfig

getTxnCommits

public Long getTxnCommits()
Specified by:
getTxnCommits in interface SessionConfig

getTxnRejects

public Long getTxnRejects()
Specified by:
getTxnRejects in interface SessionConfig

getTxnCount

public Long getTxnCount()
Specified by:
getTxnCount in interface SessionConfig

getChannelId

public int getChannelId()

setPublishFrame

public void setPublishFrame(org.apache.qpid.framing.abstraction.MessagePublishInfo info,
                            Exchange e)
                     throws org.apache.qpid.AMQSecurityException
Throws:
org.apache.qpid.AMQSecurityException

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()

getSubscription

public Subscription getSubscription(org.apache.qpid.framing.AMQShortString subscription)

subscribeToQueue

public org.apache.qpid.framing.AMQShortString subscribeToQueue(org.apache.qpid.framing.AMQShortString tag,
                                                               AMQQueue queue,
                                                               boolean acks,
                                                               org.apache.qpid.framing.FieldTable filters,
                                                               boolean noLocal,
                                                               boolean exclusive)
                                                        throws org.apache.qpid.AMQException
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
acks - Are acks enabled for this subscriber
filters - Filters to apply to this subscriber
noLocal - Flag stopping own messages being receivied.
exclusive - Flag requesting exclusive access to the queue
Returns:
the consumer tag. This is returned to the subscriber and used in subsequent unsubscribe requests
Throws:
org.apache.qpid.AMQException - if something goes wrong

unsubscribeConsumer

public boolean unsubscribeConsumer(org.apache.qpid.framing.AMQShortString consumerTag)
                            throws org.apache.qpid.AMQException
Unsubscribe a consumer from a queue.

Parameters:
consumerTag -
Returns:
true if the consumerTag had a mapped queue that could be unregistered.
Throws:
org.apache.qpid.AMQException

close

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

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

addUnacknowledgedMessage

public void addUnacknowledgedMessage(QueueEntry entry,
                                     long deliveryTag,
                                     Subscription subscription)
Add a message to the channel-based list of unacknowledged messages

Parameters:
entry - the record of the message on the queue that was delivered
deliveryTag - the delivery tag used when delivering the message (see protocol spec for description of the delivery tag)
subscription - The consumer that is to acknowledge this message.

debugIdentity

public String debugIdentity()

requeue

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

Throws:
org.apache.qpid.AMQException - if the requeue fails

requeue

public void requeue(long deliveryTag)
             throws org.apache.qpid.AMQException
Requeue a single message

Parameters:
deliveryTag - The message to requeue
Throws:
org.apache.qpid.AMQException - If something goes wrong.

resend

public void resend(boolean requeue)
            throws org.apache.qpid.AMQException
Called to resend all outstanding unacknowledged messages to this same channel.

Parameters:
requeue - Are the messages to be requeued or dropped.
Throws:
org.apache.qpid.AMQException - When something goes wrong.

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 UnacknowledgedMessageMap getUnacknowledgedMessageMap()
Used only for testing purposes.

Returns:
the map of unacknowledged messages

setSuspended

public void setSuspended(boolean suspended)
Called from the ChannelFlowHandler to suspend this Channel

Parameters:
suspended - boolean, should this Channel be 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

rollback

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

toString

public String toString()
Overrides:
toString in class Object

setDefaultQueue

public void setDefaultQueue(AMQQueue queue)

getDefaultQueue

public AMQQueue getDefaultQueue()

isClosing

public boolean isClosing()

getProtocolSession

public AMQProtocolSession getProtocolSession()

getCreditManager

public FlowCreditManager getCreditManager()

setCredit

public void setCredit(long prefetchSize,
                      int prefetchCount)

getMessageStore

public MessageStore getMessageStore()

getClientDeliveryMethod

public ClientDeliveryMethod getClientDeliveryMethod()

getRecordDeliveryMethod

public RecordDeliveryMethod getRecordDeliveryMethod()

getID

public Object getID()
Specified by:
getID in interface AMQSessionModel

getConnectionModel

public AMQConnectionModel getConnectionModel()
Specified by:
getConnectionModel in interface AMQSessionModel

getClientID

public String getClientID()
Specified by:
getClientID in interface AMQSessionModel

getLogSubject

public LogSubject getLogSubject()
Specified by:
getLogSubject in interface AMQSessionModel

getLogActor

public LogActor getLogActor()

block

public void block(AMQQueue queue)

unblock

public void unblock(AMQQueue queue)

getBlocking

public boolean getBlocking()

getVirtualHost

public VirtualHost getVirtualHost()
Specified by:
getVirtualHost in interface SessionConfig

getParent

public ConfiguredObject getParent()
Specified by:
getParent in interface ConfiguredObject<SessionConfigType,SessionConfig>

getConfigType

public SessionConfigType getConfigType()
Specified by:
getConfigType in interface ConfiguredObject<SessionConfigType,SessionConfig>

getChannel

public int getChannel()
Specified by:
getChannel in interface SessionConfig

isAttached

public boolean isAttached()
Specified by:
isAttached in interface SessionConfig

getDetachedLifespan

public long getDetachedLifespan()
Specified by:
getDetachedLifespan in interface SessionConfig

getConnectionConfig

public ConnectionConfig getConnectionConfig()
Specified by:
getConnectionConfig in interface SessionConfig

getExpiryTime

public Long getExpiryTime()
Specified by:
getExpiryTime in interface SessionConfig

getMaxClientRate

public Long getMaxClientRate()
Specified by:
getMaxClientRate in interface SessionConfig

isDurable

public boolean isDurable()
Specified by:
isDurable in interface ConfiguredObject<SessionConfigType,SessionConfig>

getId

public UUID getId()
Specified by:
getId in interface ConfiguredObject<SessionConfigType,SessionConfig>

getSessionName

public String getSessionName()
Specified by:
getSessionName in interface SessionConfig

getCreateTime

public long getCreateTime()
Specified by:
getCreateTime in interface ConfiguredObject<SessionConfigType,SessionConfig>

mgmtClose

public void mgmtClose()
               throws org.apache.qpid.AMQException
Specified by:
mgmtClose in interface SessionConfig
Throws:
org.apache.qpid.AMQException


Licensed to the Apache Software Foundation