org.apache.qpid.client
Class AMQSession<C extends BasicMessageConsumer,P extends BasicMessageProducer>

java.lang.Object
  extended by org.apache.qpid.client.Closeable
      extended by org.apache.qpid.client.AMQSession<C,P>
All Implemented Interfaces:
Runnable, QueueSession, Session, TopicSession
Direct Known Subclasses:
AMQSession_0_10, AMQSession_0_8

public abstract class AMQSession<C extends BasicMessageConsumer,P extends BasicMessageProducer>
extends Closeable
implements Session, QueueSession, TopicSession

CRC Card
Responsibilities Collaborations

Todo:
Different FailoverSupport implementation are needed on the same method call, in different situations. For example, when failing-over and reestablishing the bindings, the bind cannot be interrupted by a second fail-over, if it fails with an exception, the fail-over process should also fail. When binding outside of the fail-over process, the retry handler could be used to automatically retry the operation once the connection has been reestablished. All fail-over protected operations should be placed in private methods, with FailoverSupport passed in by the caller to provide the correct support for the calling context. Sometimes the fail-over process sets a nowait flag and uses an async method call instead., Two new objects created on every failover supported method call. Consider more efficient ways of doing this, after looking at worse bottlenecks first.

Nested Class Summary
static interface AMQSession.Dispatchable
           
(package private)  class AMQSession.Dispatcher
          Responsible for decoding a message fragment and passing it to the appropriate message consumer.
static class AMQSession.IdToConsumerMap<C extends BasicMessageConsumer>
           
 
Field Summary
protected  int _acknowledgeMode
          Holds the sessions acknowledgement mode.
protected  int _channelId
          Holds this session unique identifier, used to distinguish it from other sessions.
protected  AMQConnection _connection
          The connection to which this session belongs.
protected  AMQSession.IdToConsumerMap<C> _consumers
          Maps from identifying tags to message consumers, in order to pass dispatch incoming messages to the right consumer.
protected  ConcurrentLinkedQueue<Long> _deliveredMessageTags
          All the delivered message tags
protected  AMQSession.Dispatcher _dispatcher
          Holds the dispatcher thread for this session.
protected  Thread _dispatcherThread
           
protected  AtomicBoolean _firstDispatcher
          Used to ensure that onlt the first call to start the dispatcher can unsuspend the channel.
protected  boolean _immediatePrefetch
          Used to indicate that the session should start pre-fetching messages as soon as it is started.
protected  MessageFactoryRegistry _messageFactoryRegistry
          Holds the message factory factory for this session.
protected  FlowControllingBlockingQueue _queue
          Used to hold incoming messages.
protected  ConcurrentHashMap<C,String> _reverseSubscriptionMap
          Holds a mapping from message consumers to their identifying names, so that their subscriptions may be looked up in the _subscriptions map.
protected  boolean _strictAMQP
          Indicates that warnings should be generated on violations of the strict AMQP.
protected  boolean _strictAMQPFATAL
          Indicates that runtime exceptions should be generated on vilations of the strict AMQP.
protected  Lock _subscriberAccess
           
protected  Lock _subscriberDetails
          Locks to keep access to subscriber details atomic.
protected  ConcurrentHashMap<String,TopicSubscriberAdaptor<C>> _subscriptions
          Used to reference durable subscribers so that requests for unsubscribe can be handled correctly.
(package private)  AMQSession<C,P> _thisSession
           
protected  boolean _transacted
          Used to indicate whether or not this is a transactional session.
protected  ConcurrentLinkedQueue<Long> _unacknowledgedMessageTags
          All the not yet acknowledged message tags
protected  boolean DECLARE_EXCHANGES
           
protected  boolean DECLARE_QUEUES
           
static long DEFAULT_FLOW_CONTROL_WAIT_FAILURE
          The period to wait while flow controlled before declaring a failure
protected  boolean DEFAULT_IMMEDIATE
          The default value for immediate flag used by producers created by this session is false.
protected  boolean DEFAULT_MANDATORY
          The default value for mandatory flag used by producers created by this session is true.
protected  boolean DEFAULT_WAIT_ON_SEND
           
protected  long FLOW_CONTROL_WAIT_FAILURE
           
protected  long FLOW_CONTROL_WAIT_PERIOD
          The period to wait while flow controlled before sending a log message confirming that the session is still waiting on flow control being revoked
static String IMMEDIATE_PREFETCH
          System property to enable immediate message prefetching.
static String IMMEDIATE_PREFETCH_DEFAULT
          Immediate message prefetch default.
static String STRICT_AMQP
          System property to enable strict AMQP compliance.
static String STRICT_AMQP_DEFAULT
          Strict AMQP default setting.
static String STRICT_AMQP_FATAL
          System property to enable failure if strict AMQP compliance is violated.
static String STRICT_AMQP_FATAL_DEFAULT
          Strickt AMQP failure default.
protected  boolean USE_AMQP_ENCODED_MAP_MESSAGE
           
 
Fields inherited from class org.apache.qpid.client.Closeable
_closed, _closing
 
Fields inherited from interface org.apache.qpid.jms.Session
NO_ACKNOWLEDGE, PRE_ACKNOWLEDGE
 
Fields inherited from interface javax.jms.Session
AUTO_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, SESSION_TRANSACTED
 
Constructor Summary
(package private) AMQSession(AMQConnection con, int channelId, boolean transacted, int acknowledgeMode, int defaultPrefetchHigh, int defaultPrefetchLow)
          Creates a new session on a connection with the default message factory factory.
protected AMQSession(AMQConnection con, int channelId, boolean transacted, int acknowledgeMode, MessageFactoryRegistry messageFactoryRegistry, int defaultPrefetchHighMark, int defaultPrefetchLowMark)
          Creates a new session on a connection.
 
Method Summary
 void acknowledge()
          Acknowledges all unacknowledged messages on the session, for all message consumers on the session.
abstract  void acknowledgeMessage(long deliveryTag, boolean multiple)
          Acknowledge one or many messages.
 void addBindingKey(C consumer, AMQDestination amqd, String routingKey)
           
protected  void addDeliveredMessage(long id)
           
protected  void addUnacknowledgedMessage(long id)
           
 void bindQueue(org.apache.qpid.framing.AMQShortString queueName, org.apache.qpid.framing.AMQShortString routingKey, org.apache.qpid.framing.FieldTable arguments, org.apache.qpid.framing.AMQShortString exchangeName, AMQDestination destination)
          Binds the named queue, with the specified routing key, to the named exchange.
 void bindQueue(org.apache.qpid.framing.AMQShortString queueName, org.apache.qpid.framing.AMQShortString routingKey, org.apache.qpid.framing.FieldTable arguments, org.apache.qpid.framing.AMQShortString exchangeName, AMQDestination destination, boolean nowait)
           
 void checkFlowControl()
           
 void checkNotClosed()
          Checks if this is closed, and raises a JMSException if it is.
protected  void checkTransacted()
           
protected  AMQTopic checkValidTopic(Topic topic)
           
protected  AMQTopic checkValidTopic(Topic topic, boolean durable)
           
 void close()
          Closes the session with no timeout.
 void close(long timeout)
          Closes the session.
 void closed(Throwable e)
          Called when the server initiates the closure of the session unilaterally.
 void commit()
          Commits all messages done in this transaction and releases any locks currently held.
 void confirmConsumerCancelled(int consumerTag)
           
 QueueBrowser createBrowser(Queue queue)
           
 QueueBrowser createBrowser(Queue queue, String messageSelector)
           
 MessageConsumer createBrowserConsumer(Destination destination, String messageSelector, boolean noLocal)
           
 BytesMessage createBytesMessage()
           
 MessageConsumer createConsumer(Destination destination)
           
 MessageConsumer createConsumer(Destination destination, int prefetch, boolean noLocal, boolean exclusive, String selector)
           
 MessageConsumer createConsumer(Destination destination, int prefetch, boolean noLocal, boolean exclusive, String selector, org.apache.qpid.framing.FieldTable rawSelector)
           
 MessageConsumer createConsumer(Destination destination, int prefetchHigh, int prefetchLow, boolean noLocal, boolean exclusive, String selector)
           
 MessageConsumer createConsumer(Destination destination, int prefetchHigh, int prefetchLow, boolean noLocal, boolean exclusive, String selector, org.apache.qpid.framing.FieldTable rawSelector)
           
 MessageConsumer createConsumer(Destination destination, String messageSelector)
           
 MessageConsumer createConsumer(Destination destination, String messageSelector, boolean noLocal)
           
protected  C createConsumerImpl(Destination destination, int prefetchHigh, int prefetchLow, boolean noLocal, boolean exclusive, String selector, org.apache.qpid.framing.FieldTable rawSelector, boolean noConsume, boolean autoClose)
           
 TopicSubscriber createDurableSubscriber(Topic topic, String name)
           
 TopicSubscriber createDurableSubscriber(Topic topic, String name, String selector, boolean noLocal)
           
 C createExclusiveConsumer(Destination destination)
           
 MessageConsumer createExclusiveConsumer(Destination destination, String messageSelector, boolean noLocal)
           
 MapMessage createMapMessage()
           
 Message createMessage()
           
abstract  C createMessageConsumer(AMQDestination destination, int prefetchHigh, int prefetchLow, boolean noLocal, boolean exclusive, String selector, org.apache.qpid.framing.FieldTable arguments, boolean noConsume, boolean autoClose)
           
abstract  P createMessageProducer(Destination destination, boolean mandatory, boolean immediate, boolean waitUntilSent, long producerId)
           
 ObjectMessage createObjectMessage()
           
 ObjectMessage createObjectMessage(Serializable object)
           
 P createProducer(Destination destination)
           
 P createProducer(Destination destination, boolean immediate)
          Create a producer
 P createProducer(Destination destination, boolean mandatory, boolean immediate)
          Create a producer
 P createProducer(Destination destination, boolean mandatory, boolean immediate, boolean waitUntilSent)
           
 TopicPublisher createPublisher(Topic topic)
           
 void createQueue(org.apache.qpid.framing.AMQShortString name, boolean autoDelete, boolean durable, boolean exclusive)
          Declares the named queue.
 void createQueue(org.apache.qpid.framing.AMQShortString name, boolean autoDelete, boolean durable, boolean exclusive, Map<String,Object> arguments)
          Declares the named queue.
 Queue createQueue(String queueName)
           
 QueueReceiver createQueueReceiver(Destination destination)
          Creates a QueueReceiver
 QueueReceiver createQueueReceiver(Destination destination, String messageSelector)
          Creates a QueueReceiver using a message selector
 QueueReceiver createReceiver(Queue queue)
          Creates a QueueReceiver wrapping a MessageConsumer
 QueueReceiver createReceiver(Queue queue, String messageSelector)
          Creates a QueueReceiver wrapping a MessageConsumer using a message selector
 QueueSender createSender(Queue queue)
           
 StreamMessage createStreamMessage()
           
 TopicSubscriber createSubscriber(Topic topic)
          Creates a non-durable subscriber
 TopicSubscriber createSubscriber(Topic topic, String messageSelector, boolean noLocal)
          Creates a non-durable subscriber with a message selector
 TemporaryQueue createTemporaryQueue()
           
 TemporaryTopic createTemporaryTopic()
           
 TextMessage createTextMessage()
           
 TextMessage createTextMessage(String text)
           
 Topic createTopic(String topicName)
           
 void declareAndBind(AMQDestination amqd)
           
 void declareExchange(org.apache.qpid.framing.AMQShortString name, org.apache.qpid.framing.AMQShortString type, boolean nowait)
           
protected  org.apache.qpid.framing.AMQShortString declareQueue(AMQDestination amqd, AMQProtocolHandler protocolHandler, boolean noLocal)
          Declares a queue for a JMS destination.
protected  org.apache.qpid.framing.AMQShortString declareQueue(AMQDestination amqd, AMQProtocolHandler protocolHandler, boolean noLocal, boolean nowait)
           
protected  void deleteQueue(org.apache.qpid.framing.AMQShortString queueName)
          Undeclares the specified queue.
(package private)  void deregisterConsumer(C consumer)
          Called by the MessageConsumer when closing, to deregister the consumer from the map from consumerTag to consumer instance.
(package private)  void deregisterProducer(long producerId)
           
 void dispatch(UnprocessedMessage message)
           
(package private)  void failoverPrep()
           
protected abstract  void flushAcknowledgments()
           
 int getAcknowledgeMode()
           
 AMQConnection getAMQConnection()
           
 int getChannelId()
           
 int getDefaultPrefetch()
           
 int getDefaultPrefetchHigh()
           
 int getDefaultPrefetchLow()
           
 org.apache.qpid.framing.AMQShortString getDefaultQueueExchangeName()
           
 org.apache.qpid.framing.AMQShortString getDefaultTopicExchangeName()
           
protected  Object getFailoverMutex()
           
abstract  AMQMessageDelegateFactory getMessageDelegateFactory()
           
(package private)  Object getMessageDeliveryLock()
           
 MessageListener getMessageListener()
           
 org.apache.qpid.framing.MethodRegistry getMethodRegistry()
           
protected  AMQProtocolHandler getProtocolHandler()
           
 byte getProtocolMajorVersion()
           
 byte getProtocolMinorVersion()
           
 long getQueueDepth(AMQDestination amqd)
          Returns the number of messages currently queued for the given destination.
 org.apache.qpid.framing.AMQShortString getTemporaryQueueExchangeName()
           
 org.apache.qpid.framing.AMQShortString getTemporaryTopicExchangeName()
           
 int getTicket()
           
 boolean getTransacted()
           
abstract  void handleAddressBasedDestination(AMQDestination dest, boolean isConsumer, boolean noWait)
           
 boolean hasConsumer(Destination destination)
           
 boolean hasFailedOver()
          Check to see if failover has occured since the last call to markClean(commit or rollback).
protected  boolean hasMessageListeners()
           
 boolean isClosed()
          Checks if the Session and its parent connection are closed
 boolean isClosing()
          Checks if the Session and its parent connection are capable of performing closing operations
 boolean isDirty()
          Check to see if any message have been sent in this transaction and have not been commited.
(package private)  boolean isInRecovery()
           
abstract  boolean isQueueBound(AMQDestination destination)
           
(package private)  boolean isQueueBound(org.apache.qpid.framing.AMQShortString exchangeName, org.apache.qpid.framing.AMQShortString queueName)
           
abstract  boolean isQueueBound(org.apache.qpid.framing.AMQShortString exchangeName, org.apache.qpid.framing.AMQShortString queueName, org.apache.qpid.framing.AMQShortString routingKey)
          Tests whether or not the specified queue is bound to the specified exchange under a particular routing key.
abstract  boolean isQueueBound(String exchangeName, String queueName, String bindingKey, Map<String,Object> args)
           
(package private)  boolean isStarted()
           
 boolean isStrictAMQP()
           
 boolean isSuspended()
           
 void markClean()
          Signifies that the session has no pending sends to commit.
(package private)  void markClosed()
          Called to mark the session as being closed.
 void markDirty()
          Signifies that the session has pending sends to commit.
 void messageReceived(UnprocessedMessage message)
          Invoked by the MINA IO thread (indirectly) when a message is received from the transport.
 boolean prefetch()
          Indicates whether this session consumers pre-fetche messages
 void recover()
          Stops message delivery in this session, and restarts message delivery with the oldest unacknowledged message.
 void rejectMessage(AbstractJMSMessage message, boolean requeue)
           
abstract  void rejectMessage(long deliveryTag, boolean requeue)
           
 void rejectMessage(UnprocessedMessage message, boolean requeue)
           
abstract  void releaseForRollback()
           
protected abstract  Long requestQueueDepth(AMQDestination amqd)
           
(package private)  void resubscribe()
          Resubscribes all producers and consumers.
 void rollback()
          Commits all messages done in this transaction and releases any locks currently held.
 void run()
           
abstract  void sendClose(long timeout)
           
abstract  void sendCommit()
           
abstract  void sendConsume(C consumer, org.apache.qpid.framing.AMQShortString queueName, AMQProtocolHandler protocolHandler, boolean nowait, String messageSelector, int tag)
           
abstract  void sendCreateQueue(org.apache.qpid.framing.AMQShortString name, boolean autoDelete, boolean durable, boolean exclusive, Map<String,Object> arguments)
           
abstract  void sendExchangeDeclare(org.apache.qpid.framing.AMQShortString name, org.apache.qpid.framing.AMQShortString type, AMQProtocolHandler protocolHandler, boolean nowait)
           
abstract  void sendQueueBind(org.apache.qpid.framing.AMQShortString queueName, org.apache.qpid.framing.AMQShortString routingKey, org.apache.qpid.framing.FieldTable arguments, org.apache.qpid.framing.AMQShortString exchangeName, AMQDestination destination, boolean nowait)
           
abstract  void sendQueueDeclare(AMQDestination amqd, AMQProtocolHandler protocolHandler, boolean nowait)
           
abstract  void sendQueueDelete(org.apache.qpid.framing.AMQShortString queueName)
           
protected abstract  void sendRecover()
           
abstract  void sendRollback()
           
abstract  void sendSuspendChannel(boolean suspend)
           
 void setFlowControl(boolean active)
           
(package private)  void setHasMessageListeners()
           
(package private)  void setInRecovery(boolean inRecovery)
           
 void setMessageListener(MessageListener listener)
           
 void setTicket(int ticket)
           
(package private)  void start()
          Starts the session, which ensures that it is not suspended and that its event dispatcher is running.
(package private)  void startDispatcherIfNecessary()
           
(package private)  void startDispatcherIfNecessary(boolean initiallyStopped)
           
(package private)  void stop()
           
protected  void suspendChannel(boolean suspend)
          Suspends or unsuspends this session.
abstract  void sync()
           
(package private)  void syncDispatchQueue()
           
protected abstract  boolean tagLE(long tag1, long tag2)
           
 void unsubscribe(String name)
           
protected abstract  boolean updateRollbackMark(long current, long deliveryTag)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_thisSession

final AMQSession<C extends BasicMessageConsumer,P extends BasicMessageProducer> _thisSession

DEFAULT_IMMEDIATE

protected final boolean DEFAULT_IMMEDIATE
The default value for immediate flag used by producers created by this session is false. That is, a consumer does not need to be attached to a queue.


DEFAULT_MANDATORY

protected final boolean DEFAULT_MANDATORY
The default value for mandatory flag used by producers created by this session is true. That is, server will not silently drop messages where no queue is connected to the exchange for the message.


DEFAULT_WAIT_ON_SEND

protected final boolean DEFAULT_WAIT_ON_SEND

FLOW_CONTROL_WAIT_PERIOD

protected final long FLOW_CONTROL_WAIT_PERIOD
The period to wait while flow controlled before sending a log message confirming that the session is still waiting on flow control being revoked


DEFAULT_FLOW_CONTROL_WAIT_FAILURE

public static final long DEFAULT_FLOW_CONTROL_WAIT_FAILURE
The period to wait while flow controlled before declaring a failure

See Also:
Constant Field Values

FLOW_CONTROL_WAIT_FAILURE

protected final long FLOW_CONTROL_WAIT_FAILURE

DECLARE_QUEUES

protected final boolean DECLARE_QUEUES

DECLARE_EXCHANGES

protected final boolean DECLARE_EXCHANGES

USE_AMQP_ENCODED_MAP_MESSAGE

protected final boolean USE_AMQP_ENCODED_MAP_MESSAGE

STRICT_AMQP

public static final String STRICT_AMQP
System property to enable strict AMQP compliance.

See Also:
Constant Field Values

STRICT_AMQP_DEFAULT

public static final String STRICT_AMQP_DEFAULT
Strict AMQP default setting.

See Also:
Constant Field Values

STRICT_AMQP_FATAL

public static final String STRICT_AMQP_FATAL
System property to enable failure if strict AMQP compliance is violated.

See Also:
Constant Field Values

STRICT_AMQP_FATAL_DEFAULT

public static final String STRICT_AMQP_FATAL_DEFAULT
Strickt AMQP failure default.

See Also:
Constant Field Values

IMMEDIATE_PREFETCH

public static final String IMMEDIATE_PREFETCH
System property to enable immediate message prefetching.

See Also:
Constant Field Values

IMMEDIATE_PREFETCH_DEFAULT

public static final String IMMEDIATE_PREFETCH_DEFAULT
Immediate message prefetch default.

See Also:
Constant Field Values

_connection

protected AMQConnection _connection
The connection to which this session belongs.


_transacted

protected boolean _transacted
Used to indicate whether or not this is a transactional session.


_acknowledgeMode

protected final int _acknowledgeMode
Holds the sessions acknowledgement mode.


_channelId

protected int _channelId
Holds this session unique identifier, used to distinguish it from other sessions.


_subscriptions

protected final ConcurrentHashMap<String,TopicSubscriberAdaptor<C extends BasicMessageConsumer>> _subscriptions
Used to reference durable subscribers so that requests for unsubscribe can be handled correctly. Note this only keeps a record of subscriptions which have been created in the current instance. It does not remember subscriptions between executions of the client.


_reverseSubscriptionMap

protected final ConcurrentHashMap<C extends BasicMessageConsumer,String> _reverseSubscriptionMap
Holds a mapping from message consumers to their identifying names, so that their subscriptions may be looked up in the _subscriptions map.


_subscriberDetails

protected final Lock _subscriberDetails
Locks to keep access to subscriber details atomic.

Added for QPID2418


_subscriberAccess

protected final Lock _subscriberAccess

_queue

protected final FlowControllingBlockingQueue _queue
Used to hold incoming messages.

Todo:
Weaken the type once FlowControllingBlockingQueue implements Queue.

_unacknowledgedMessageTags

protected ConcurrentLinkedQueue<Long> _unacknowledgedMessageTags
All the not yet acknowledged message tags


_deliveredMessageTags

protected ConcurrentLinkedQueue<Long> _deliveredMessageTags
All the delivered message tags


_dispatcher

protected AMQSession.Dispatcher _dispatcher
Holds the dispatcher thread for this session.


_dispatcherThread

protected Thread _dispatcherThread

_messageFactoryRegistry

protected MessageFactoryRegistry _messageFactoryRegistry
Holds the message factory factory for this session.


_consumers

protected final AMQSession.IdToConsumerMap<C extends BasicMessageConsumer> _consumers
Maps from identifying tags to message consumers, in order to pass dispatch incoming messages to the right consumer.


_firstDispatcher

protected final AtomicBoolean _firstDispatcher
Used to ensure that onlt the first call to start the dispatcher can unsuspend the channel.

Todo:
This is accessed only within a synchronized method, so does not need to be atomic.

_immediatePrefetch

protected final boolean _immediatePrefetch
Used to indicate that the session should start pre-fetching messages as soon as it is started.


_strictAMQP

protected final boolean _strictAMQP
Indicates that warnings should be generated on violations of the strict AMQP.


_strictAMQPFATAL

protected final boolean _strictAMQPFATAL
Indicates that runtime exceptions should be generated on vilations of the strict AMQP.

Constructor Detail

AMQSession

protected AMQSession(AMQConnection con,
                     int channelId,
                     boolean transacted,
                     int acknowledgeMode,
                     MessageFactoryRegistry messageFactoryRegistry,
                     int defaultPrefetchHighMark,
                     int defaultPrefetchLowMark)
Creates a new session on a connection.

Parameters:
con - The connection on which to create the session.
channelId - The unique identifier for the session.
transacted - Indicates whether or not the session is transactional.
acknowledgeMode - The acknoledgement mode for the session.
messageFactoryRegistry - The message factory factory for the session.
defaultPrefetchHighMark - The maximum number of messages to prefetched before suspending the session.
defaultPrefetchLowMark - The number of prefetched messages at which to resume the session.

AMQSession

AMQSession(AMQConnection con,
           int channelId,
           boolean transacted,
           int acknowledgeMode,
           int defaultPrefetchHigh,
           int defaultPrefetchLow)
Creates a new session on a connection with the default message factory factory.

Parameters:
con - The connection on which to create the session.
channelId - The unique identifier for the session.
transacted - Indicates whether or not the session is transactional.
acknowledgeMode - The acknoledgement mode for the session.
defaultPrefetchHigh - The maximum number of messages to prefetched before suspending the session.
defaultPrefetchLow - The number of prefetched messages at which to resume the session.
Method Detail

close

public void close()
           throws JMSException
Closes the session with no timeout.

Specified by:
close in interface Session
Specified by:
close in class Closeable
Throws:
JMSException - If the JMS provider fails to close the session due to some internal error.

checkNotClosed

public void checkNotClosed()
                    throws JMSException
Description copied from class: Closeable
Checks if this is closed, and raises a JMSException if it is.

Overrides:
checkNotClosed in class Closeable
Throws:
JMSException - If this is closed.

createBytesMessage

public BytesMessage createBytesMessage()
                                throws JMSException
Specified by:
createBytesMessage in interface Session
Throws:
JMSException

acknowledge

public void acknowledge()
                 throws IllegalStateException
Acknowledges all unacknowledged messages on the session, for all message consumers on the session.

Throws:
IllegalStateException - If the session is closed.

acknowledgeMessage

public abstract void acknowledgeMessage(long deliveryTag,
                                        boolean multiple)
Acknowledge one or many messages.

Parameters:
deliveryTag - The tag of the last message to be acknowledged.
multiple - true to acknowledge all messages up to and including the one specified by the delivery tag, false to just acknowledge that message.
Todo:
Be aware of possible changes to parameter order as versions change.

getMethodRegistry

public org.apache.qpid.framing.MethodRegistry getMethodRegistry()

bindQueue

public void bindQueue(org.apache.qpid.framing.AMQShortString queueName,
                      org.apache.qpid.framing.AMQShortString routingKey,
                      org.apache.qpid.framing.FieldTable arguments,
                      org.apache.qpid.framing.AMQShortString exchangeName,
                      AMQDestination destination)
               throws org.apache.qpid.AMQException
Binds the named queue, with the specified routing key, to the named exchange.

Note that this operation automatically retries in the event of fail-over.

Parameters:
queueName - The name of the queue to bind.
routingKey - The routing key to bind the queue with.
arguments - Additional arguments.
exchangeName - The exchange to bind the queue on.
Throws:
org.apache.qpid.AMQException - If the queue cannot be bound for any reason.
Todo:
Be aware of possible changes to parameter order as versions change., Document the additional arguments that may be passed in the field table. Are these for headers exchanges?

bindQueue

public void bindQueue(org.apache.qpid.framing.AMQShortString queueName,
                      org.apache.qpid.framing.AMQShortString routingKey,
                      org.apache.qpid.framing.FieldTable arguments,
                      org.apache.qpid.framing.AMQShortString exchangeName,
                      AMQDestination destination,
                      boolean nowait)
               throws org.apache.qpid.AMQException
Throws:
org.apache.qpid.AMQException

addBindingKey

public void addBindingKey(C consumer,
                          AMQDestination amqd,
                          String routingKey)
                   throws org.apache.qpid.AMQException
Throws:
org.apache.qpid.AMQException

sendQueueBind

public abstract void sendQueueBind(org.apache.qpid.framing.AMQShortString queueName,
                                   org.apache.qpid.framing.AMQShortString routingKey,
                                   org.apache.qpid.framing.FieldTable arguments,
                                   org.apache.qpid.framing.AMQShortString exchangeName,
                                   AMQDestination destination,
                                   boolean nowait)
                            throws org.apache.qpid.AMQException,
                                   FailoverException
Throws:
org.apache.qpid.AMQException
FailoverException

close

public void close(long timeout)
           throws JMSException
Closes the session.

Note that this operation succeeds automatically if a fail-over interupts the sycnronous request to close the channel. This is because the channel is marked as closed before the request to close it is made, so the fail-over should not re-open it.

Parameters:
timeout - The timeout in milliseconds to wait for the session close acknoledgement from the broker.
Throws:
JMSException - If the JMS provider fails to close the session due to some internal error.
Todo:
Be aware of possible changes to parameter order as versions change., Not certain about the logic of ignoring the failover exception, because the channel won't be re-opened. May need to examine this more carefully., Note that taking the failover mutex doesn't prevent this operation being interrupted by a failover, because the failover process sends the failover event before acquiring the mutex itself.

sendClose

public abstract void sendClose(long timeout)
                        throws org.apache.qpid.AMQException,
                               FailoverException
Throws:
org.apache.qpid.AMQException
FailoverException

closed

public void closed(Throwable e)
            throws JMSException
Called when the server initiates the closure of the session unilaterally.

Parameters:
e - the exception that caused this session to be closed. Null causes the
Throws:
JMSException

commit

public void commit()
            throws JMSException
Commits all messages done in this transaction and releases any locks currently held.

If the commit fails, because the commit itself is interrupted by a fail-over between requesting that the commit be done, and receiving an acknowledgement that it has been done, then a JMSException will be thrown. The client will be unable to determine whether or not the commit actually happened on the broker in this case.

Specified by:
commit in interface Session
Throws:
JMSException - If the JMS provider fails to commit the transaction due to some internal error. This does not mean that the commit is known to have failed, merely that it is not known whether it failed or not.
Todo:
Be aware of possible changes to parameter order as versions change.

sendCommit

public abstract void sendCommit()
                         throws org.apache.qpid.AMQException,
                                FailoverException
Throws:
org.apache.qpid.AMQException
FailoverException

confirmConsumerCancelled

public void confirmConsumerCancelled(int consumerTag)

createBrowser

public QueueBrowser createBrowser(Queue queue)
                           throws JMSException
Specified by:
createBrowser in interface QueueSession
Specified by:
createBrowser in interface Session
Throws:
JMSException

createBrowser

public QueueBrowser createBrowser(Queue queue,
                                  String messageSelector)
                           throws JMSException
Specified by:
createBrowser in interface QueueSession
Specified by:
createBrowser in interface Session
Throws:
JMSException

createBrowserConsumer

public MessageConsumer createBrowserConsumer(Destination destination,
                                             String messageSelector,
                                             boolean noLocal)
                                      throws JMSException
Throws:
JMSException

createConsumer

public MessageConsumer createConsumer(Destination destination)
                               throws JMSException
Specified by:
createConsumer in interface Session
Throws:
JMSException

createExclusiveConsumer

public C createExclusiveConsumer(Destination destination)
                                                       throws JMSException
Throws:
JMSException

createConsumer

public MessageConsumer createConsumer(Destination destination,
                                      String messageSelector)
                               throws JMSException
Specified by:
createConsumer in interface Session
Throws:
JMSException

createConsumer

public MessageConsumer createConsumer(Destination destination,
                                      String messageSelector,
                                      boolean noLocal)
                               throws JMSException
Specified by:
createConsumer in interface Session
Throws:
JMSException

createExclusiveConsumer

public MessageConsumer createExclusiveConsumer(Destination destination,
                                               String messageSelector,
                                               boolean noLocal)
                                        throws JMSException
Throws:
JMSException

createConsumer

public MessageConsumer createConsumer(Destination destination,
                                      int prefetch,
                                      boolean noLocal,
                                      boolean exclusive,
                                      String selector)
                               throws JMSException
Throws:
JMSException

createConsumer

public MessageConsumer createConsumer(Destination destination,
                                      int prefetchHigh,
                                      int prefetchLow,
                                      boolean noLocal,
                                      boolean exclusive,
                                      String selector)
                               throws JMSException
Throws:
JMSException

createConsumer

public MessageConsumer createConsumer(Destination destination,
                                      int prefetch,
                                      boolean noLocal,
                                      boolean exclusive,
                                      String selector,
                                      org.apache.qpid.framing.FieldTable rawSelector)
                               throws JMSException
Throws:
JMSException

createConsumer

public MessageConsumer createConsumer(Destination destination,
                                      int prefetchHigh,
                                      int prefetchLow,
                                      boolean noLocal,
                                      boolean exclusive,
                                      String selector,
                                      org.apache.qpid.framing.FieldTable rawSelector)
                               throws JMSException
Throws:
JMSException

createDurableSubscriber

public TopicSubscriber createDurableSubscriber(Topic topic,
                                               String name)
                                        throws JMSException
Specified by:
createDurableSubscriber in interface Session
Specified by:
createDurableSubscriber in interface TopicSession
Throws:
JMSException

createDurableSubscriber

public TopicSubscriber createDurableSubscriber(Topic topic,
                                               String name,
                                               String selector,
                                               boolean noLocal)
                                        throws JMSException
Specified by:
createDurableSubscriber in interface Session
Specified by:
createDurableSubscriber in interface TopicSession
Throws:
JMSException

createMapMessage

public MapMessage createMapMessage()
                            throws JMSException
Specified by:
createMapMessage in interface Session
Throws:
JMSException

createMessage

public Message createMessage()
                      throws JMSException
Specified by:
createMessage in interface Session
Throws:
JMSException

createObjectMessage

public ObjectMessage createObjectMessage()
                                  throws JMSException
Specified by:
createObjectMessage in interface Session
Throws:
JMSException

createObjectMessage

public ObjectMessage createObjectMessage(Serializable object)
                                  throws JMSException
Specified by:
createObjectMessage in interface Session
Throws:
JMSException

createProducer

public P createProducer(Destination destination)
                                              throws JMSException
Specified by:
createProducer in interface Session
Throws:
JMSException

createProducer

public P createProducer(Destination destination,
                        boolean immediate)
                                              throws JMSException
Description copied from interface: Session
Create a producer

immediate - the value of the immediate flag used by default on the producer
Returns:
Throws:
JMSException

createProducer

public P createProducer(Destination destination,
                        boolean mandatory,
                        boolean immediate)
                                              throws JMSException
Description copied from interface: Session
Create a producer

mandatory - the value of the mandatory flag used by default on the producer
immediate - the value of the immediate flag used by default on the producer
Returns:
Throws:
JMSException

createProducer

public P createProducer(Destination destination,
                        boolean mandatory,
                        boolean immediate,
                        boolean waitUntilSent)
                                              throws JMSException
Throws:
JMSException

createPublisher

public TopicPublisher createPublisher(Topic topic)
                               throws JMSException
Specified by:
createPublisher in interface TopicSession
Throws:
JMSException

createQueue

public Queue createQueue(String queueName)
                  throws JMSException
Specified by:
createQueue in interface QueueSession
Specified by:
createQueue in interface Session
Throws:
JMSException

createQueue

public void createQueue(org.apache.qpid.framing.AMQShortString name,
                        boolean autoDelete,
                        boolean durable,
                        boolean exclusive)
                 throws org.apache.qpid.AMQException
Declares the named queue.

Note that this operation automatically retries in the event of fail-over.

Parameters:
name - The name of the queue to declare.
autoDelete -
durable - Flag to indicate that the queue is durable.
exclusive - Flag to indicate that the queue is exclusive to this client.
Throws:
org.apache.qpid.AMQException - If the queue cannot be declared for any reason.
Todo:
Be aware of possible changes to parameter order as versions change.

createQueue

public void createQueue(org.apache.qpid.framing.AMQShortString name,
                        boolean autoDelete,
                        boolean durable,
                        boolean exclusive,
                        Map<String,Object> arguments)
                 throws org.apache.qpid.AMQException
Declares the named queue.

Note that this operation automatically retries in the event of fail-over.

Parameters:
name - The name of the queue to declare.
autoDelete -
durable - Flag to indicate that the queue is durable.
exclusive - Flag to indicate that the queue is exclusive to this client.
arguments - Arguments used to set special properties of the queue
Throws:
org.apache.qpid.AMQException - If the queue cannot be declared for any reason.
Todo:
Be aware of possible changes to parameter order as versions change.

sendCreateQueue

public abstract void sendCreateQueue(org.apache.qpid.framing.AMQShortString name,
                                     boolean autoDelete,
                                     boolean durable,
                                     boolean exclusive,
                                     Map<String,Object> arguments)
                              throws org.apache.qpid.AMQException,
                                     FailoverException
Throws:
org.apache.qpid.AMQException
FailoverException

createQueueReceiver

public QueueReceiver createQueueReceiver(Destination destination)
                                  throws JMSException
Creates a QueueReceiver

Parameters:
destination -
Returns:
QueueReceiver - a wrapper around our MessageConsumer
Throws:
JMSException

createQueueReceiver

public QueueReceiver createQueueReceiver(Destination destination,
                                         String messageSelector)
                                  throws JMSException
Creates a QueueReceiver using a message selector

Parameters:
destination -
messageSelector -
Returns:
QueueReceiver - a wrapper around our MessageConsumer
Throws:
JMSException

createReceiver

public QueueReceiver createReceiver(Queue queue)
                             throws JMSException
Creates a QueueReceiver wrapping a MessageConsumer

Specified by:
createReceiver in interface QueueSession
Parameters:
queue -
Returns:
QueueReceiver
Throws:
JMSException

createReceiver

public QueueReceiver createReceiver(Queue queue,
                                    String messageSelector)
                             throws JMSException
Creates a QueueReceiver wrapping a MessageConsumer using a message selector

Specified by:
createReceiver in interface QueueSession
Parameters:
queue -
messageSelector -
Returns:
QueueReceiver
Throws:
JMSException

createSender

public QueueSender createSender(Queue queue)
                         throws JMSException
Specified by:
createSender in interface QueueSession
Throws:
JMSException

createStreamMessage

public StreamMessage createStreamMessage()
                                  throws JMSException
Specified by:
createStreamMessage in interface Session
Throws:
JMSException

createSubscriber

public TopicSubscriber createSubscriber(Topic topic)
                                 throws JMSException
Creates a non-durable subscriber

Specified by:
createSubscriber in interface TopicSession
Parameters:
topic -
Returns:
TopicSubscriber - a wrapper round our MessageConsumer
Throws:
JMSException

createSubscriber

public TopicSubscriber createSubscriber(Topic topic,
                                        String messageSelector,
                                        boolean noLocal)
                                 throws JMSException
Creates a non-durable subscriber with a message selector

Specified by:
createSubscriber in interface TopicSession
Parameters:
topic -
messageSelector -
noLocal -
Returns:
TopicSubscriber - a wrapper round our MessageConsumer
Throws:
JMSException

createTemporaryQueue

public TemporaryQueue createTemporaryQueue()
                                    throws JMSException
Specified by:
createTemporaryQueue in interface QueueSession
Specified by:
createTemporaryQueue in interface Session
Throws:
JMSException

createTemporaryTopic

public TemporaryTopic createTemporaryTopic()
                                    throws JMSException
Specified by:
createTemporaryTopic in interface Session
Specified by:
createTemporaryTopic in interface TopicSession
Throws:
JMSException

createTextMessage

public TextMessage createTextMessage()
                              throws JMSException
Specified by:
createTextMessage in interface Session
Throws:
JMSException

getFailoverMutex

protected Object getFailoverMutex()

createTextMessage

public TextMessage createTextMessage(String text)
                              throws JMSException
Specified by:
createTextMessage in interface Session
Throws:
JMSException

createTopic

public Topic createTopic(String topicName)
                  throws JMSException
Specified by:
createTopic in interface Session
Specified by:
createTopic in interface TopicSession
Throws:
JMSException

declareExchange

public void declareExchange(org.apache.qpid.framing.AMQShortString name,
                            org.apache.qpid.framing.AMQShortString type,
                            boolean nowait)
                     throws org.apache.qpid.AMQException
Throws:
org.apache.qpid.AMQException

sync

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

getAcknowledgeMode

public int getAcknowledgeMode()
                       throws JMSException
Specified by:
getAcknowledgeMode in interface Session
Throws:
JMSException

getAMQConnection

public AMQConnection getAMQConnection()

getChannelId

public int getChannelId()

getDefaultPrefetch

public int getDefaultPrefetch()
Returns:
the prefetch value used by default for consumers created on this session.

getDefaultPrefetchHigh

public int getDefaultPrefetchHigh()
Returns:
the High water prefetch value used by default for consumers created on this session.

getDefaultPrefetchLow

public int getDefaultPrefetchLow()
Returns:
the Low water prefetch value used by default for consumers created on this session.

getDefaultQueueExchangeName

public org.apache.qpid.framing.AMQShortString getDefaultQueueExchangeName()

getDefaultTopicExchangeName

public org.apache.qpid.framing.AMQShortString getDefaultTopicExchangeName()

getMessageListener

public MessageListener getMessageListener()
                                   throws JMSException
Specified by:
getMessageListener in interface Session
Throws:
JMSException

getTemporaryQueueExchangeName

public org.apache.qpid.framing.AMQShortString getTemporaryQueueExchangeName()

getTemporaryTopicExchangeName

public org.apache.qpid.framing.AMQShortString getTemporaryTopicExchangeName()

getTicket

public int getTicket()

getTransacted

public boolean getTransacted()
                      throws JMSException
Specified by:
getTransacted in interface Session
Throws:
JMSException

hasConsumer

public boolean hasConsumer(Destination destination)

isStrictAMQP

public boolean isStrictAMQP()

isSuspended

public boolean isSuspended()

addUnacknowledgedMessage

protected void addUnacknowledgedMessage(long id)

addDeliveredMessage

protected void addDeliveredMessage(long id)

messageReceived

public void messageReceived(UnprocessedMessage message)
Invoked by the MINA IO thread (indirectly) when a message is received from the transport. Puts the message onto the queue read by the dispatcher.

Parameters:
message - the message that has been received

declareAndBind

public void declareAndBind(AMQDestination amqd)
                    throws org.apache.qpid.AMQException
Throws:
org.apache.qpid.AMQException

recover

public void recover()
             throws JMSException
Stops message delivery in this session, and restarts message delivery with the oldest unacknowledged message.

All consumers deliver messages in a serial order. Acknowledging a received message automatically acknowledges all messages that have been delivered to the client.

Restarting a session causes it to take the following actions:

If the recover operation is interrupted by a fail-over, between asking that the broker begin recovery and receiving acknowledgment that it has then a JMSException will be thrown. In this case it will not be possible for the client to determine whether the broker is going to recover the session or not.

Specified by:
recover in interface Session
Throws:
JMSException - If the JMS provider fails to stop and restart message delivery due to some internal error. Not that this does not necessarily mean that the recovery has failed, but simply that it is not possible to tell if it has or not.
Todo:
Be aware of possible changes to parameter order as versions change. Strategy for handling recover. Flush any acks not yet sent. Stop the message flow. Clear the dispatch queue and the consumer queues. Release/Reject all messages received but not yet acknowledged. Start the message flow.

sendRecover

protected abstract void sendRecover()
                             throws org.apache.qpid.AMQException,
                                    FailoverException
Throws:
org.apache.qpid.AMQException
FailoverException

flushAcknowledgments

protected abstract void flushAcknowledgments()

rejectMessage

public void rejectMessage(UnprocessedMessage message,
                          boolean requeue)

rejectMessage

public void rejectMessage(AbstractJMSMessage message,
                          boolean requeue)

rejectMessage

public abstract void rejectMessage(long deliveryTag,
                                   boolean requeue)

rollback

public void rollback()
              throws JMSException
Commits all messages done in this transaction and releases any locks currently held.

If the rollback fails, because the rollback itself is interrupted by a fail-over between requesting that the rollback be done, and receiving an acknowledgement that it has been done, then a JMSException will be thrown. The client will be unable to determine whether or not the rollback actually happened on the broker in this case.

Specified by:
rollback in interface Session
Throws:
JMSException - If the JMS provider fails to rollback the transaction due to some internal error. This does not mean that the rollback is known to have failed, merely that it is not known whether it failed or not.
Todo:
Be aware of possible changes to parameter order as versions change.

releaseForRollback

public abstract void releaseForRollback()

sendRollback

public abstract void sendRollback()
                           throws org.apache.qpid.AMQException,
                                  FailoverException
Throws:
org.apache.qpid.AMQException
FailoverException

run

public void run()
Specified by:
run in interface Runnable
Specified by:
run in interface Session

setMessageListener

public void setMessageListener(MessageListener listener)
                        throws JMSException
Specified by:
setMessageListener in interface Session
Throws:
JMSException

unsubscribe

public void unsubscribe(String name)
                 throws JMSException
Specified by:
unsubscribe in interface Session
Specified by:
unsubscribe in interface TopicSession
Throws:
JMSException
See Also:
unsubscribe(String, boolean)

createConsumerImpl

protected C createConsumerImpl(Destination destination,
                               int prefetchHigh,
                               int prefetchLow,
                               boolean noLocal,
                               boolean exclusive,
                               String selector,
                               org.apache.qpid.framing.FieldTable rawSelector,
                               boolean noConsume,
                               boolean autoClose)
                                                     throws JMSException
Throws:
JMSException

createMessageConsumer

public abstract C createMessageConsumer(AMQDestination destination,
                                        int prefetchHigh,
                                        int prefetchLow,
                                        boolean noLocal,
                                        boolean exclusive,
                                        String selector,
                                        org.apache.qpid.framing.FieldTable arguments,
                                        boolean noConsume,
                                        boolean autoClose)
                                                              throws JMSException
Throws:
JMSException

deregisterConsumer

void deregisterConsumer(C consumer)
Called by the MessageConsumer when closing, to deregister the consumer from the map from consumerTag to consumer instance.

Parameters:
consumer - the consum

deregisterProducer

void deregisterProducer(long producerId)

isInRecovery

boolean isInRecovery()

isQueueBound

boolean isQueueBound(org.apache.qpid.framing.AMQShortString exchangeName,
                     org.apache.qpid.framing.AMQShortString queueName)
               throws JMSException
Throws:
JMSException

isQueueBound

public abstract boolean isQueueBound(org.apache.qpid.framing.AMQShortString exchangeName,
                                     org.apache.qpid.framing.AMQShortString queueName,
                                     org.apache.qpid.framing.AMQShortString routingKey)
                              throws JMSException
Tests whether or not the specified queue is bound to the specified exchange under a particular routing key.

Note that this operation automatically retries in the event of fail-over.

Parameters:
exchangeName - The exchange name to test for binding against.
queueName - The queue name to check if bound.
routingKey - The routing key to check if the queue is bound under.
Returns:
true if the queue is bound to the exchange and routing key, false if not.
Throws:
JMSException - If the query fails for any reason.
Todo:
Be aware of possible changes to parameter order as versions change.

isQueueBound

public abstract boolean isQueueBound(AMQDestination destination)
                              throws JMSException
Throws:
JMSException

isQueueBound

public abstract boolean isQueueBound(String exchangeName,
                                     String queueName,
                                     String bindingKey,
                                     Map<String,Object> args)
                              throws JMSException
Throws:
JMSException

markClosed

void markClosed()
Called to mark the session as being closed. Useful when the session needs to be made invalid, e.g. after failover when the client has veoted resubscription.

The caller of this method must already hold the failover mutex.


failoverPrep

void failoverPrep()

syncDispatchQueue

void syncDispatchQueue()

resubscribe

void resubscribe()
           throws org.apache.qpid.AMQException
Resubscribes all producers and consumers. This is called when performing failover.

Throws:
org.apache.qpid.AMQException

setHasMessageListeners

void setHasMessageListeners()

setInRecovery

void setInRecovery(boolean inRecovery)

isStarted

boolean isStarted()

start

void start()
     throws org.apache.qpid.AMQException
Starts the session, which ensures that it is not suspended and that its event dispatcher is running.

Throws:
org.apache.qpid.AMQException - If the session cannot be started for any reason.
Todo:
This should be controlled by _stopped as it pairs with the stop method fixme or check the FlowControlledBlockingQueue _queue to see if we have flow controlled. will result in sending Flow messages for each subsequent call to flow.. only need to do this if we have called stop.

startDispatcherIfNecessary

void startDispatcherIfNecessary()

startDispatcherIfNecessary

void startDispatcherIfNecessary(boolean initiallyStopped)

stop

void stop()
    throws org.apache.qpid.AMQException
Throws:
org.apache.qpid.AMQException

checkTransacted

protected void checkTransacted()
                        throws JMSException
Throws:
JMSException

checkValidTopic

protected AMQTopic checkValidTopic(Topic topic,
                                   boolean durable)
                            throws JMSException
Throws:
JMSException

checkValidTopic

protected AMQTopic checkValidTopic(Topic topic)
                            throws JMSException
Throws:
JMSException

sendConsume

public abstract void sendConsume(C consumer,
                                 org.apache.qpid.framing.AMQShortString queueName,
                                 AMQProtocolHandler protocolHandler,
                                 boolean nowait,
                                 String messageSelector,
                                 int tag)
                          throws org.apache.qpid.AMQException,
                                 FailoverException
Throws:
org.apache.qpid.AMQException
FailoverException

createMessageProducer

public abstract P createMessageProducer(Destination destination,
                                        boolean mandatory,
                                        boolean immediate,
                                        boolean waitUntilSent,
                                        long producerId)

getQueueDepth

public long getQueueDepth(AMQDestination amqd)
                   throws org.apache.qpid.AMQException
Returns the number of messages currently queued for the given destination.

Note that this operation automatically retries in the event of fail-over.

Parameters:
amqd - The destination to be checked
Returns:
the number of queued messages.
Throws:
org.apache.qpid.AMQException - If the queue cannot be declared for any reason.

requestQueueDepth

protected abstract Long requestQueueDepth(AMQDestination amqd)
                                   throws org.apache.qpid.AMQException,
                                          FailoverException
Throws:
org.apache.qpid.AMQException
FailoverException

sendExchangeDeclare

public abstract void sendExchangeDeclare(org.apache.qpid.framing.AMQShortString name,
                                         org.apache.qpid.framing.AMQShortString type,
                                         AMQProtocolHandler protocolHandler,
                                         boolean nowait)
                                  throws org.apache.qpid.AMQException,
                                         FailoverException
Throws:
org.apache.qpid.AMQException
FailoverException

declareQueue

protected org.apache.qpid.framing.AMQShortString declareQueue(AMQDestination amqd,
                                                              AMQProtocolHandler protocolHandler,
                                                              boolean noLocal)
                                                       throws org.apache.qpid.AMQException
Declares a queue for a JMS destination.

Note that for queues but not topics the name is generated in the client rather than the server. This allows the name to be reused on failover if required. In general, the destination indicates whether it wants a name generated or not.

Note that this operation automatically retries in the event of fail-over.

Parameters:
amqd - The destination to declare as a queue.
protocolHandler - The protocol handler to communicate through.
Returns:
The name of the decalred queue. This is useful where the broker is generating a queue name on behalf of the client.
Throws:
org.apache.qpid.AMQException - If the queue cannot be declared for any reason.
Todo:
Verify the destiation is valid or throw an exception., Be aware of possible changes to parameter order as versions change.

declareQueue

protected org.apache.qpid.framing.AMQShortString declareQueue(AMQDestination amqd,
                                                              AMQProtocolHandler protocolHandler,
                                                              boolean noLocal,
                                                              boolean nowait)
                                                       throws org.apache.qpid.AMQException
Throws:
org.apache.qpid.AMQException

sendQueueDeclare

public abstract void sendQueueDeclare(AMQDestination amqd,
                                      AMQProtocolHandler protocolHandler,
                                      boolean nowait)
                               throws org.apache.qpid.AMQException,
                                      FailoverException
Throws:
org.apache.qpid.AMQException
FailoverException

deleteQueue

protected void deleteQueue(org.apache.qpid.framing.AMQShortString queueName)
                    throws JMSException
Undeclares the specified queue.

Note that this operation automatically retries in the event of fail-over.

Parameters:
queueName - The name of the queue to delete.
Throws:
JMSException - If the queue could not be deleted for any reason.
Todo:
Be aware of possible changes to parameter order as versions change.

sendQueueDelete

public abstract void sendQueueDelete(org.apache.qpid.framing.AMQShortString queueName)
                              throws org.apache.qpid.AMQException,
                                     FailoverException
Throws:
org.apache.qpid.AMQException
FailoverException

getProtocolHandler

protected AMQProtocolHandler getProtocolHandler()

getProtocolMajorVersion

public byte getProtocolMajorVersion()

getProtocolMinorVersion

public byte getProtocolMinorVersion()

hasMessageListeners

protected boolean hasMessageListeners()

handleAddressBasedDestination

public abstract void handleAddressBasedDestination(AMQDestination dest,
                                                   boolean isConsumer,
                                                   boolean noWait)
                                            throws org.apache.qpid.AMQException
Throws:
org.apache.qpid.AMQException

suspendChannel

protected void suspendChannel(boolean suspend)
                       throws org.apache.qpid.AMQException
Suspends or unsuspends this session.

Parameters:
suspend - true indicates that the session should be suspended, false indicates that it should be unsuspended.
Throws:
org.apache.qpid.AMQException - If the session cannot be suspended for any reason.
Todo:
Be aware of possible changes to parameter order as versions change.

sendSuspendChannel

public abstract void sendSuspendChannel(boolean suspend)
                                 throws org.apache.qpid.AMQException,
                                        FailoverException
Throws:
org.apache.qpid.AMQException
FailoverException

getMessageDeliveryLock

Object getMessageDeliveryLock()

prefetch

public boolean prefetch()
Indicates whether this session consumers pre-fetche messages

Returns:
true if this session consumers pre-fetche messages false otherwise

markDirty

public void markDirty()
Signifies that the session has pending sends to commit.


markClean

public void markClean()
Signifies that the session has no pending sends to commit.


hasFailedOver

public boolean hasFailedOver()
Check to see if failover has occured since the last call to markClean(commit or rollback).

Returns:
boolean true if failover has occured.

isDirty

public boolean isDirty()
Check to see if any message have been sent in this transaction and have not been commited.

Returns:
boolean true if a message has been sent but not commited

setTicket

public void setTicket(int ticket)

setFlowControl

public void setFlowControl(boolean active)

checkFlowControl

public void checkFlowControl()
                      throws InterruptedException,
                             JMSException
Throws:
InterruptedException
JMSException

dispatch

public void dispatch(UnprocessedMessage message)

tagLE

protected abstract boolean tagLE(long tag1,
                                 long tag2)

updateRollbackMark

protected abstract boolean updateRollbackMark(long current,
                                              long deliveryTag)

getMessageDelegateFactory

public abstract AMQMessageDelegateFactory getMessageDelegateFactory()

isClosed

public boolean isClosed()
Checks if the Session and its parent connection are closed

Overrides:
isClosed in class Closeable
Returns:
true if this is closed, false otherwise.

isClosing

public boolean isClosing()
Checks if the Session and its parent connection are capable of performing closing operations

Overrides:
isClosing in class Closeable
Returns:
true if we are closing, false otherwise.


Licensed to the Apache Software Foundation