org.apache.qpid.client
Class AMQSession

java.lang.Object
  extended by org.apache.qpid.client.Closeable
      extended by org.apache.qpid.client.AMQSession
All Implemented Interfaces:
java.lang.Runnable, javax.jms.QueueSession, javax.jms.Session, javax.jms.TopicSession

public class AMQSession
extends Closeable
implements Session, javax.jms.QueueSession, javax.jms.TopicSession


Field Summary
protected static boolean DEFAULT_IMMEDIATE
          Default value for immediate flag used by producers created by this session is false, i.e.
protected static boolean DEFAULT_MANDATORY
          Default value for mandatory flag used by producers created by this sessio is true, i.e.
static int DEFAULT_PREFETCH_HIGH_MARK
           
static int DEFAULT_PREFETCH_LOW_MARK
           
 
Fields inherited from class org.apache.qpid.client.Closeable
_closed
 
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
 
Fields inherited from interface javax.jms.Session
AUTO_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, SESSION_TRANSACTED
 
Fields inherited from interface javax.jms.Session
AUTO_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, SESSION_TRANSACTED
 
Method Summary
 void acknowledgeMessage(long deliveryTag, boolean multiple)
          Acknowledge a message or several messages.
 void close()
           
 void closed(java.lang.Throwable e)
          Called when the server initiates the closure of the session unilaterally.
 void commit()
           
 javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue)
           
 javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue, java.lang.String messageSelector)
           
 javax.jms.BytesMessage createBytesMessage()
           
 javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination)
           
 javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, int prefetch, boolean noLocal, boolean exclusive, java.lang.String selector)
           
 javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, int prefetch, boolean noLocal, boolean exclusive, java.lang.String selector, org.apache.qpid.framing.FieldTable rawSelector)
           
 javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, int prefetchHigh, int prefetchLow, boolean noLocal, boolean exclusive, java.lang.String selector)
           
 javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, int prefetchHigh, int prefetchLow, boolean noLocal, boolean exclusive, java.lang.String selector, org.apache.qpid.framing.FieldTable rawSelector)
           
 javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, java.lang.String messageSelector)
           
 javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, java.lang.String messageSelector, boolean noLocal)
           
protected  javax.jms.MessageConsumer createConsumerImpl(javax.jms.Destination destination, int prefetchHigh, int prefetchLow, boolean noLocal, boolean exclusive, java.lang.String selector, org.apache.qpid.framing.FieldTable rawSelector)
           
 javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic, java.lang.String name)
          Note, currently this does not handle reuse of the same name with different topics correctly.
 javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic, java.lang.String name, java.lang.String messageSelector, boolean noLocal)
          Note, currently this does not handle reuse of the same name with different topics correctly.
 javax.jms.MapMessage createMapMessage()
           
 javax.jms.Message createMessage()
           
 javax.jms.ObjectMessage createObjectMessage()
           
 javax.jms.ObjectMessage createObjectMessage(java.io.Serializable object)
           
 javax.jms.MessageProducer createProducer(javax.jms.Destination destination)
           
 javax.jms.MessageProducer createProducer(javax.jms.Destination destination, boolean immediate)
           
 javax.jms.MessageProducer createProducer(javax.jms.Destination destination, boolean mandatory, boolean immediate)
           
 javax.jms.MessageProducer createProducer(javax.jms.Destination destination, boolean mandatory, boolean immediate, boolean waitUntilSent)
           
 javax.jms.TopicPublisher createPublisher(javax.jms.Topic topic)
           
 javax.jms.Queue createQueue(java.lang.String queueName)
           
 javax.jms.QueueReceiver createQueueReceiver(javax.jms.Destination destination)
          Creates a QueueReceiver
 javax.jms.QueueReceiver createQueueReceiver(javax.jms.Destination destination, java.lang.String messageSelector)
          Creates a QueueReceiver using a message selector
 javax.jms.QueueReceiver createReceiver(javax.jms.Queue queue)
          Creates a QueueReceiver wrapping a MessageConsumer
 javax.jms.QueueReceiver createReceiver(javax.jms.Queue queue, java.lang.String messageSelector)
          Creates a QueueReceiver wrapping a MessageConsumer using a message selector
 javax.jms.QueueSender createSender(javax.jms.Queue queue)
           
 javax.jms.StreamMessage createStreamMessage()
           
 javax.jms.TopicSubscriber createSubscriber(javax.jms.Topic topic)
          Creates a non-durable subscriber
 javax.jms.TopicSubscriber createSubscriber(javax.jms.Topic topic, java.lang.String messageSelector, boolean noLocal)
          Creates a non-durable subscriber with a message selector
 javax.jms.TemporaryQueue createTemporaryQueue()
           
 javax.jms.TemporaryTopic createTemporaryTopic()
           
 javax.jms.TextMessage createTextMessage()
           
 javax.jms.TextMessage createTextMessage(java.lang.String text)
           
 javax.jms.Topic createTopic(java.lang.String topicName)
           
 void declareExchange(java.lang.String name, java.lang.String type)
           
 void declareExchangeSynch(java.lang.String name, java.lang.String type)
           
 int getAcknowledgeMode()
           
 int getChannelId()
           
 int getDefaultPrefetch()
           
 int getDefaultPrefetchHigh()
           
 int getDefaultPrefetchLow()
           
 javax.jms.MessageListener getMessageListener()
           
 boolean getTransacted()
           
 void messageReceived(UnprocessedMessage message)
          Invoked by the MINA IO thread (indirectly) when a message is received from the transport.
 void recover()
          Asks the broker to resend all unacknowledged messages for the session.
 void rollback()
           
 void run()
           
 void setMessageListener(javax.jms.MessageListener listener)
           
 void unsubscribe(java.lang.String name)
           
 
Methods inherited from class org.apache.qpid.client.Closeable
checkNotClosed, isClosed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PREFETCH_HIGH_MARK

public static final int DEFAULT_PREFETCH_HIGH_MARK
See Also:
Constant Field Values

DEFAULT_PREFETCH_LOW_MARK

public static final int DEFAULT_PREFETCH_LOW_MARK
See Also:
Constant Field Values

DEFAULT_IMMEDIATE

protected static final boolean DEFAULT_IMMEDIATE
Default value for immediate flag used by producers created by this session is false, i.e. a consumer does not need to be attached to a queue

See Also:
Constant Field Values

DEFAULT_MANDATORY

protected static final boolean DEFAULT_MANDATORY
Default value for mandatory flag used by producers created by this sessio is true, i.e. server will not silently drop messages where no queue is connected to the exchange for the message

See Also:
Constant Field Values
Method Detail

createBytesMessage

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

createMapMessage

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

createMessage

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

createObjectMessage

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

createObjectMessage

public javax.jms.ObjectMessage createObjectMessage(java.io.Serializable object)
                                            throws javax.jms.JMSException
Specified by:
createObjectMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

createStreamMessage

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

createTextMessage

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

createTextMessage

public javax.jms.TextMessage createTextMessage(java.lang.String text)
                                        throws javax.jms.JMSException
Specified by:
createTextMessage in interface javax.jms.Session
Throws:
javax.jms.JMSException

getTransacted

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

getAcknowledgeMode

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

commit

public void commit()
            throws javax.jms.JMSException
Specified by:
commit in interface javax.jms.Session
Throws:
javax.jms.JMSException

rollback

public void rollback()
              throws javax.jms.JMSException
Specified by:
rollback in interface javax.jms.Session
Throws:
javax.jms.JMSException

close

public void close()
           throws javax.jms.JMSException
Specified by:
close in interface javax.jms.Session
Specified by:
close in class Closeable
Throws:
javax.jms.JMSException

closed

public void closed(java.lang.Throwable e)
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

recover

public void recover()
             throws javax.jms.JMSException
Asks the broker to resend all unacknowledged messages for the session.

Specified by:
recover in interface javax.jms.Session
Throws:
javax.jms.JMSException

getMessageListener

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

setMessageListener

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

run

public void run()
Specified by:
run in interface java.lang.Runnable
Specified by:
run in interface javax.jms.Session

createProducer

public javax.jms.MessageProducer createProducer(javax.jms.Destination destination,
                                                boolean mandatory,
                                                boolean immediate,
                                                boolean waitUntilSent)
                                         throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createProducer

public javax.jms.MessageProducer createProducer(javax.jms.Destination destination,
                                                boolean mandatory,
                                                boolean immediate)
                                         throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createProducer

public javax.jms.MessageProducer createProducer(javax.jms.Destination destination,
                                                boolean immediate)
                                         throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createProducer

public javax.jms.MessageProducer createProducer(javax.jms.Destination destination)
                                         throws javax.jms.JMSException
Specified by:
createProducer in interface javax.jms.Session
Throws:
javax.jms.JMSException

createQueueReceiver

public javax.jms.QueueReceiver createQueueReceiver(javax.jms.Destination destination)
                                            throws javax.jms.JMSException
Creates a QueueReceiver

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

createQueueReceiver

public javax.jms.QueueReceiver createQueueReceiver(javax.jms.Destination destination,
                                                   java.lang.String messageSelector)
                                            throws javax.jms.JMSException
Creates a QueueReceiver using a message selector

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

createConsumer

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

createConsumer

public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination,
                                                java.lang.String messageSelector)
                                         throws javax.jms.JMSException
Specified by:
createConsumer in interface javax.jms.Session
Throws:
javax.jms.JMSException

createConsumer

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

createConsumer

public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination,
                                                int prefetch,
                                                boolean noLocal,
                                                boolean exclusive,
                                                java.lang.String selector)
                                         throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createConsumer

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

createConsumer

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

createConsumer

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

createConsumerImpl

protected javax.jms.MessageConsumer createConsumerImpl(javax.jms.Destination destination,
                                                       int prefetchHigh,
                                                       int prefetchLow,
                                                       boolean noLocal,
                                                       boolean exclusive,
                                                       java.lang.String selector,
                                                       org.apache.qpid.framing.FieldTable rawSelector)
                                                throws javax.jms.JMSException
Throws:
javax.jms.JMSException

declareExchange

public void declareExchange(java.lang.String name,
                            java.lang.String type)

declareExchangeSynch

public void declareExchangeSynch(java.lang.String name,
                                 java.lang.String type)
                          throws org.apache.qpid.AMQException
Throws:
org.apache.qpid.AMQException

createQueue

public javax.jms.Queue createQueue(java.lang.String queueName)
                            throws javax.jms.JMSException
Specified by:
createQueue in interface javax.jms.QueueSession
Specified by:
createQueue in interface javax.jms.Session
Throws:
javax.jms.JMSException

createReceiver

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

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

createReceiver

public javax.jms.QueueReceiver createReceiver(javax.jms.Queue queue,
                                              java.lang.String messageSelector)
                                       throws javax.jms.JMSException
Creates a QueueReceiver wrapping a MessageConsumer using a message selector

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

createSender

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

createTopic

public javax.jms.Topic createTopic(java.lang.String topicName)
                            throws javax.jms.JMSException
Specified by:
createTopic in interface javax.jms.Session
Specified by:
createTopic in interface javax.jms.TopicSession
Throws:
javax.jms.JMSException

createSubscriber

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

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

createSubscriber

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

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

createDurableSubscriber

public javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic,
                                                         java.lang.String name)
                                                  throws javax.jms.JMSException
Note, currently this does not handle reuse of the same name with different topics correctly. If a name is reused in creating a new subscriber with a different topic/selecto or no-local flag then the subcriber will receive messages matching the old subscription AND the new one. The spec states that the new one should replace the old one. TODO: fix it.

Specified by:
createDurableSubscriber in interface javax.jms.Session
Specified by:
createDurableSubscriber in interface javax.jms.TopicSession
Throws:
javax.jms.JMSException

createDurableSubscriber

public javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic,
                                                         java.lang.String name,
                                                         java.lang.String messageSelector,
                                                         boolean noLocal)
                                                  throws javax.jms.JMSException
Note, currently this does not handle reuse of the same name with different topics correctly.

Specified by:
createDurableSubscriber in interface javax.jms.Session
Specified by:
createDurableSubscriber in interface javax.jms.TopicSession
Throws:
javax.jms.JMSException

createPublisher

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

createBrowser

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

createBrowser

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

createTemporaryQueue

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

createTemporaryTopic

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

unsubscribe

public void unsubscribe(java.lang.String name)
                 throws javax.jms.JMSException
Specified by:
unsubscribe in interface javax.jms.Session
Specified by:
unsubscribe in interface javax.jms.TopicSession
Throws:
javax.jms.JMSException

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

acknowledgeMessage

public void acknowledgeMessage(long deliveryTag,
                               boolean multiple)
Acknowledge a message or several messages. This method can be called via AbstractJMSMessage or from a BasicConsumer. The former where the mode is CLIENT_ACK and the latter where the mode is AUTO_ACK or similar.

Parameters:
deliveryTag - the tag of the last message to be acknowledged
multiple - if true will acknowledge all messages up to and including the one specified by the delivery tag

getDefaultPrefetch

public int getDefaultPrefetch()

getDefaultPrefetchHigh

public int getDefaultPrefetchHigh()

getDefaultPrefetchLow

public int getDefaultPrefetchLow()

getChannelId

public int getChannelId()