net.sf.dropboxmq.sessions
Class QueueSessionImpl

java.lang.Object
  extended by net.sf.dropboxmq.sessions.SessionImpl
      extended by net.sf.dropboxmq.sessions.QueueSessionImpl
All Implemented Interfaces:
Runnable, QueueSession, Session

public class QueueSessionImpl
extends SessionImpl
implements QueueSession

Created: 09 Oct 2005

Version:
$Revision: 211 $, $Date: 2010-11-14 14:21:24 -0700 (Sun, 14 Nov 2010) $
Author:
Dwayne Schultz

Field Summary
 
Fields inherited from interface javax.jms.Session
AUTO_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, SESSION_TRANSACTED
 
Constructor Summary
QueueSessionImpl(DropboxTransaction dropboxTransaction, ConnectionImpl connection, Configuration configuration)
           
QueueSessionImpl(SessionImpl realSession)
           
 
Method Summary
 TopicSubscriber createDurableSubscriber(Topic topic, String name)
          Creates a durable subscriber to the specified topic.
 TopicSubscriber createDurableSubscriber(Topic topic, String name, String messageSelector, boolean noLocal)
          Creates a durable subscriber to the specified topic, using a message selector and specifying whether messages published by its own connection should be delivered to it.
 QueueReceiver createReceiver(Queue queue)
          Creates a QueueReceiver object to receive messages from the specified queue.
 QueueReceiver createReceiver(Queue queue, String messageSelector)
          Creates a QueueReceiver object to receive messages from the specified queue using a message selector.
 QueueSender createSender(Queue queue)
          Creates a QueueSender object to send messages to the specified queue.
 TemporaryTopic createTemporaryTopic()
          Creates a TemporaryTopic object.
 Topic createTopic(String topicName)
          Creates a topic identity given a Topic name.
 void unsubscribe(String name)
          Unsubscribes a durable subscription that has been created by a client.
 
Methods inherited from class net.sf.dropboxmq.sessions.SessionImpl
acknowledge, addMessageConsumer, checkClosed, close, commit, createBrowser, createBrowser, createBytesMessage, createConsumer, createConsumer, createConsumer, createMapMessage, createMessage, createObjectMessage, createObjectMessage, createProducer, createQueue, createStreamMessage, createTemporaryQueue, createTextMessage, createTextMessage, getAcknowledgeMode, getAcknowledgeModeString, getConfiguration, getConnection, getDropboxTransaction, getMessageListener, getNewID, getTransacted, newDropbox, recover, removeMessageConsumer, rollback, rollbackReparentingFromChild, run, setEndpointConsumer, setMessageListener, start, startReparentingMessageToChild, stop, toObjectString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.jms.QueueSession
createBrowser, createBrowser, createQueue, createTemporaryQueue
 
Methods inherited from interface javax.jms.Session
close, commit, createBytesMessage, createConsumer, createConsumer, createConsumer, createMapMessage, createMessage, createObjectMessage, createObjectMessage, createProducer, createStreamMessage, createTextMessage, createTextMessage, getAcknowledgeMode, getMessageListener, getTransacted, recover, rollback, run, setMessageListener
 

Constructor Detail

QueueSessionImpl

public QueueSessionImpl(SessionImpl realSession)

QueueSessionImpl

public QueueSessionImpl(DropboxTransaction dropboxTransaction,
                        ConnectionImpl connection,
                        Configuration configuration)
Method Detail

createReceiver

public QueueReceiver createReceiver(Queue queue)
                             throws JMSException
Description copied from interface: javax.jms.QueueSession
Creates a QueueReceiver object to receive messages from the specified queue.

Specified by:
createReceiver in interface QueueSession
Parameters:
queue - the Queue to access
Throws:
JMSException - if the session fails to create a receiver due to some internal error.

createReceiver

public QueueReceiver createReceiver(Queue queue,
                                    String messageSelector)
                             throws JMSException
Description copied from interface: javax.jms.QueueSession
Creates a QueueReceiver object to receive messages from the specified queue using a message selector.

Specified by:
createReceiver in interface QueueSession
Parameters:
queue - the Queue to access
messageSelector - only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
Throws:
JMSException - if the session fails to create a receiver due to some internal error.
InvalidSelectorException - if the message selector is invalid.

createSender

public QueueSender createSender(Queue queue)
                         throws JMSException
Description copied from interface: javax.jms.QueueSession
Creates a QueueSender object to send messages to the specified queue.

Specified by:
createSender in interface QueueSession
Parameters:
queue - the Queue to access, or null if this is an unidentified producer
Throws:
JMSException - if the session fails to create a sender due to some internal error.

createTopic

public Topic createTopic(String topicName)
                  throws JMSException
Description copied from interface: javax.jms.Session
Creates a topic identity given a Topic name.

This facility is provided for the rare cases where clients need to dynamically manipulate topic identity. This allows the creation of a topic identity with a provider-specific name. Clients that depend on this ability are not portable.

Note that this method is not for creating the physical topic. The physical creation of topics is an administrative task and is not to be initiated by the JMS API. The one exception is the creation of temporary topics, which is accomplished with the createTemporaryTopic method.

Specified by:
createTopic in interface Session
Overrides:
createTopic in class SessionImpl
Parameters:
topicName - the name of this Topic
Returns:
a Topic with the given name
Throws:
JMSException - if the session fails to create a topic due to some internal error.

createDurableSubscriber

public TopicSubscriber createDurableSubscriber(Topic topic,
                                               String name)
                                        throws JMSException
Description copied from interface: javax.jms.Session
Creates a durable subscriber to the specified topic.

If a client needs to receive all the messages published on a topic, including the ones published while the subscriber is inactive, it uses a durable TopicSubscriber. The JMS provider retains a record of this durable subscription and insures that all messages from the topic's publishers are retained until they are acknowledged by this durable subscriber or they have expired.

Sessions with durable subscribers must always provide the same client identifier. In addition, each client must specify a name that uniquely identifies (within client identifier) each durable subscription it creates. Only one session at a time can have a TopicSubscriber for a particular durable subscription.

A client can change an existing durable subscription by creating a durable TopicSubscriber with the same name and a new topic and/or message selector. Changing a durable subscriber is equivalent to unsubscribing (deleting) the old one and creating a new one.

In some cases, a connection may both publish and subscribe to a topic. The subscriber NoLocal attribute allows a subscriber to inhibit the delivery of messages published by its own connection. The default value for this attribute is false.

Specified by:
createDurableSubscriber in interface Session
Overrides:
createDurableSubscriber in class SessionImpl
Parameters:
topic - the non-temporary Topic to subscribe to
name - the name used to identify this subscription
Throws:
JMSException - if the session fails to create a subscriber due to some internal error.

createDurableSubscriber

public TopicSubscriber createDurableSubscriber(Topic topic,
                                               String name,
                                               String messageSelector,
                                               boolean noLocal)
                                        throws JMSException
Description copied from interface: javax.jms.Session
Creates a durable subscriber to the specified topic, using a message selector and specifying whether messages published by its own connection should be delivered to it.

If a client needs to receive all the messages published on a topic, including the ones published while the subscriber is inactive, it uses a durable TopicSubscriber. The JMS provider retains a record of this durable subscription and insures that all messages from the topic's publishers are retained until they are acknowledged by this durable subscriber or they have expired.

Sessions with durable subscribers must always provide the same client identifier. In addition, each client must specify a name which uniquely identifies (within client identifier) each durable subscription it creates. Only one session at a time can have a TopicSubscriber for a particular durable subscription. An inactive durable subscriber is one that exists but does not currently have a message consumer associated with it.

A client can change an existing durable subscription by creating a durable TopicSubscriber with the same name and a new topic and/or message selector. Changing a durable subscriber is equivalent to unsubscribing (deleting) the old one and creating a new one.

Specified by:
createDurableSubscriber in interface Session
Overrides:
createDurableSubscriber in class SessionImpl
Parameters:
topic - the non-temporary Topic to subscribe to
name - the name used to identify this subscription
messageSelector - only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
noLocal - if set, inhibits the delivery of messages published by its own connection
Throws:
JMSException - if the session fails to create a subscriber due to some internal error.
InvalidSelectorException - if the message selector is invalid.

createTemporaryTopic

public TemporaryTopic createTemporaryTopic()
                                    throws JMSException
Description copied from interface: javax.jms.Session
Creates a TemporaryTopic object. Its lifetime will be that of the Connection unless it is deleted earlier.

Specified by:
createTemporaryTopic in interface Session
Overrides:
createTemporaryTopic in class SessionImpl
Returns:
a temporary topic identity
Throws:
JMSException - if the session fails to create a temporary topic due to some internal error.

unsubscribe

public void unsubscribe(String name)
                 throws JMSException
Description copied from interface: javax.jms.Session
Unsubscribes a durable subscription that has been created by a client.

This method deletes the state being maintained on behalf of the subscriber by its provider.

It is erroneous for a client to delete a durable subscription while there is an active MessageConsumer or TopicSubscriber for the subscription, or while a consumed message is part of a pending transaction or has not been acknowledged in the session.

Specified by:
unsubscribe in interface Session
Overrides:
unsubscribe in class SessionImpl
Parameters:
name - the name used to identify this subscription
Throws:
JMSException - if the session fails to unsubscribe to the durable subscription due to some internal error.