com.j_spaces.jms
Class GSQueueSessionImpl

java.lang.Object
  extended by com.j_spaces.jms.GSSessionImpl
      extended by com.j_spaces.jms.GSQueueSessionImpl
All Implemented Interfaces:
Runnable, QueueSession, Session

public class GSQueueSessionImpl
extends GSSessionImpl
implements QueueSession

GigaSpaces implementation of the javax.jms.QueueSession interface. A QueueSession object provides methods for creating QueueReceiver, QueueSender, TBD -- QueueBrowser, and TemporaryQueue objects.

If there are messages that have been received but not acknowledged when a QueueSession terminates, these messages will be retained and redelivered when a consumer next accesses the queue.

A QueueSession is used for creating Point-to-Point specific objects. In general, use the Session object. The QueueSession is used to support existing code. Using the Session object simplifies the programming model, and allows transactions to be used across the two messaging domains.

A QueueSession cannot be used to create objects specific to the publish/subscribe domain. The following methods inherit from Session, but must throw an IllegalStateException if they are used from QueueSession:

See Also:
Session, QueueConnection.createQueueSession(boolean, int), XAQueueSession.getQueueSession()

Field Summary
 
Fields inherited from class com.j_spaces.jms.GSSessionImpl
ackLeaseTime, invalidSelectorIdentifiers, JMSX_CLIENT_NAMES, m_sessionID, reservedSelectorIdentifiers, txLeaseTime
 
Fields inherited from interface javax.jms.Session
AUTO_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, SESSION_TRANSACTED
 
Constructor Summary
GSQueueSessionImpl(com.j_spaces.jms.GSConnectionImpl connection, boolean transacted, int acknowledgeMode, Transaction transaction)
          Constructs a queue session.
 
Method Summary
 QueueBrowser createBrowser(Queue queue)
           
 QueueBrowser createBrowser(Queue queue, String messageSelector)
           
 TopicSubscriber createDurableSubscriber(Topic topic, String name)
          API method.
 TopicSubscriber createDurableSubscriber(Topic topic, String name, String selector, boolean noLocal)
          API method.
 Queue createQueue(String queueName)
           
 QueueReceiver createReceiver(Queue queue)
          Creates a GSQueueReceiverImpl object to receive messages from the specified queue.
 QueueReceiver createReceiver(Queue queue, String messageSelector)
          Not An API method, it is a GS implementation which uses a hashtable msg selector instead of a String.
 QueueSender createSender(Queue queue)
          Creates a QueueSender object to send messages to the specified queue.
 TemporaryQueue createTemporaryQueue()
          We use the same space proxy we obtained in the session and we write another External Entry, which will have a class name of 'TempQueue'.
 TemporaryTopic createTemporaryTopic()
           
 Topic createTopic(String topicName)
          API method.
 void unsubscribe(String name)
          API method.
 
Methods inherited from class com.j_spaces.jms.GSSessionImpl
acknowledge, cancel, close, commit, createBytesMessage, createBytesMessage, createConsumer, createConsumer, createConsumer, createMapMessage, createMapMessage, createMessage, createObjectMessage, createObjectMessage, createProducer, createStreamMessage, createTextMessage, createTextMessage, getAcknowledgeMode, getConsumersC, getJMSProviderName, getMessageListener, getMessagesC, getNumOfConsumedMsg, getNumOfProducedMsg, getProducersC, getSessionID, getTransacted, isLocalConsumer, isLocalProducer, recover, removeExternalEntryFromSpace, removeJMSAckDataEntryFromSpace, rollback, run, setConsumersC, setMessageListener, setMessagesC, setProducersC, setSessionID, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
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

GSQueueSessionImpl

public GSQueueSessionImpl(com.j_spaces.jms.GSConnectionImpl connection,
                          boolean transacted,
                          int acknowledgeMode,
                          Transaction transaction)
                   throws JMSException
Constructs a queue session.

Parameters:
connection - The connection the session belongs to.
transacted - true for a transacted session.
acknowledgeMode - 1 (auto), 2 (client) or 3 (dups ok).
transaction - transaction
Throws:
JMSException - In case of an invalid acknowledge mode.
Method Detail

createReceiver

public QueueReceiver createReceiver(Queue queue)
                             throws JMSException
Creates a GSQueueReceiverImpl object to receive messages from the specified queue. We assure that one and only one QueueReceiver is been created, using writing a JMSSessionDataEntry to the space.

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.
InvalidDestinationException - if an invalid queue is specified.
IllegalStateException - if the session is m_closed
See Also:
QueueSession.createReceiver(javax.jms.Queue)

createReceiver

public QueueReceiver createReceiver(Queue queue,
                                    String messageSelector)
                             throws JMSException
Not An API method, it is a GS implementation which uses a hashtable msg selector instead of a String. Creates a GSQueueReceiverImpl object to receive messages from the specified queue using a message selector. We assure that one and only one QueueReceiver is been created, using writing to space.

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.
InvalidDestinationException - if an invalid queue is specified.
InvalidSelectorException - if the message selector is invalid.
See Also:
QueueSession.createReceiver(javax.jms.Queue, java.lang.String)

createSender

public QueueSender createSender(Queue queue)
                         throws JMSException
Creates a QueueSender object to send messages to the specified queue. We let the client create more then a single QueueSender, but we write its instance id into the space, same as we do with the Receiver.

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.
InvalidDestinationException - if an invalid queue is specified.
See Also:
QueueSession.createSender(javax.jms.Queue)

createDurableSubscriber

public TopicSubscriber createDurableSubscriber(Topic topic,
                                               String name,
                                               String selector,
                                               boolean noLocal)
                                        throws JMSException
API method.

Specified by:
createDurableSubscriber in interface Session
Overrides:
createDurableSubscriber in class GSSessionImpl
Throws:
IllegalStateException - Systematically.
JMSException

createDurableSubscriber

public TopicSubscriber createDurableSubscriber(Topic topic,
                                               String name)
                                        throws JMSException
API method.

Specified by:
createDurableSubscriber in interface Session
Overrides:
createDurableSubscriber in class GSSessionImpl
Throws:
IllegalStateException - Systematically.
JMSException

createTopic

public Topic createTopic(String topicName)
                  throws JMSException
API method.

Specified by:
createTopic in interface Session
Overrides:
createTopic in class GSSessionImpl
Throws:
IllegalStateException - Systematically.
JMSException

createQueue

public Queue createQueue(String queueName)
                  throws JMSException
Specified by:
createQueue in interface QueueSession
Specified by:
createQueue in interface Session
Overrides:
createQueue in class GSSessionImpl
Throws:
JMSException
See Also:
Session.createQueue(java.lang.String)

createBrowser

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

createBrowser

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

createTemporaryQueue

public TemporaryQueue createTemporaryQueue()
                                    throws JMSException
We use the same space proxy we obtained in the session and we write another External Entry, which will have a class name of 'TempQueue'. The only message consumers that can consume from a temporary destination are those created by the same connection that created the destination. Any message producer can send to the temporary destination. If you close the connection that a temporary destination belongs to, the destination is closed and its contents lost. You can use temporary destinations to implement a simple request/reply mechanism. If you create a temporary destination and specify it as the value of the JMSReplyTo message header field when you send a message, the consumer of the message can use the value of the JMSReplyTo field as the destination to which it sends a reply and can also reference the original request by setting the JMSCorrelationID header field of the reply message to the value of the JMSMessageID header field of the request.

Specified by:
createTemporaryQueue in interface QueueSession
Specified by:
createTemporaryQueue in interface Session
Overrides:
createTemporaryQueue in class GSSessionImpl
Throws:
JMSException
See Also:
Session.createTemporaryQueue()

unsubscribe

public void unsubscribe(String name)
                 throws JMSException
API method.

Specified by:
unsubscribe in interface Session
Overrides:
unsubscribe in class GSSessionImpl
Throws:
IllegalStateException - Systematically.
JMSException

createTemporaryTopic

public TemporaryTopic createTemporaryTopic()
                                    throws JMSException
Specified by:
createTemporaryTopic in interface Session
Overrides:
createTemporaryTopic in class GSSessionImpl
Throws:
JMSException