com.j_spaces.jms
Class GSSessionImpl

java.lang.Object
  extended by com.j_spaces.jms.GSSessionImpl
All Implemented Interfaces:
Runnable, QueueSession, Session, TopicSession
Direct Known Subclasses:
GSQueueSessionImpl, GSTopicSessionImpl, GSXASessionImpl

public class GSSessionImpl
extends Object
implements Session, TopicSession, QueueSession, Runnable

GigaSpaces implementation of the javax.jms.Session interface.

Limitations:
- Sessions support only a single MessageConsumer.
- Durable subscribers are not supported. - StreamMessage is not supported.

See Also:
Session

Field Summary
static long txLeaseTime
           
 
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
 
Constructor Summary
GSSessionImpl(com.j_spaces.jms.GSConnectionImpl conn, boolean isTransacted, int acknowledgeMode)
          Creates a session.
 
Method Summary
 void close()
           
 void commit()
          Commits all messages done in this transaction and releases any locks currently held.
 QueueBrowser createBrowser(Queue queue)
           
 QueueBrowser createBrowser(Queue queue, String messageSelector)
           
 BytesMessage createBytesMessage()
          Creates a GSBytesMessageImpl object.
 BytesMessage createBytesMessage(byte[] bytesArrayBody)
          Creates a GSBytesMessageImpl object.
 MessageConsumer createConsumer(Destination destination)
           
 MessageConsumer createConsumer(Destination destination, String messageSelector)
           
 MessageConsumer createConsumer(Destination destination, String messageSelector, boolean noLocal)
           
 TopicSubscriber createDurableSubscriber(Topic topic, String name)
          Currently not supported.
 TopicSubscriber createDurableSubscriber(Topic topic, String name, String messageSelector, boolean noLocal)
          Currently not supported.
 MapMessage createMapMessage()
          Creates a GSMapMessageImpl object.
 Message createMessage()
           
 ObjectMessage createObjectMessage()
          Creates a GSObjectMessageImpl object.
 ObjectMessage createObjectMessage(Serializable object)
          Creates a GSObjectMessageImpl object.
 MessageProducer createProducer(Destination destination)
           
 TopicPublisher createPublisher(Topic topic)
           
 Queue createQueue(String queueName)
           
 QueueReceiver createReceiver(Queue queue)
           
 QueueReceiver createReceiver(Queue queue, String messageSelector)
           
 QueueSender createSender(Queue queue)
           
 StreamMessage createStreamMessage()
          Creates a StreamMessage object.
 TopicSubscriber createSubscriber(Topic topic)
           
 TopicSubscriber createSubscriber(Topic topic, String messageSelector, boolean noLocal)
           
 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()
          Creates a TemporaryTopic object.
 TextMessage createTextMessage()
          Creates an initialized TextMessage object.
 TextMessage createTextMessage(String text)
          Creates an initialized TextMessage object.
 Topic createTopic(String topicName)
           
 int getAcknowledgeMode()
          JMS 1.1 API
 int getConsumersC()
           
 String getJMSProviderName()
           
 MessageListener getMessageListener()
           
 int getMessagesC()
           
 int getNumOfConsumedMsg()
           
 int getNumOfProducedMsg()
           
 int getProducersC()
           
 String getSessionID()
           
 boolean getTransacted()
           
 void recover()
           
 void rollback()
          API method for m_tx rollback Calling the space LocalTransactionManager m_tx.abort()
 void run()
           
 void setConsumersC(int i)
           
 void setMessageListener(MessageListener listener)
           
 void setMessagesC(int i)
           
 void setProducersC(int i)
           
 void setSessionID(String string)
           
 String toString()
           
 void unsubscribe(String subscriptionName)
          Currently not supported.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

txLeaseTime

public static final long txLeaseTime
See Also:
Constant Field Values
Constructor Detail

GSSessionImpl

public GSSessionImpl(com.j_spaces.jms.GSConnectionImpl conn,
                     boolean isTransacted,
                     int acknowledgeMode)
              throws JMSException
Creates a session.

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

getJMSProviderName

public String getJMSProviderName()

createBytesMessage

public BytesMessage createBytesMessage()
                                throws JMSException
Creates a GSBytesMessageImpl object. A BytesMessage object is used to send a message containing a stream of uninterpreted bytes.

Specified by:
createBytesMessage in interface Session
Throws:
JMSException - if the JMS provider fails to create this message due to some internal error.
IllegalStateException - If the session is closed.
See Also:
Session.createBytesMessage()

createBytesMessage

public BytesMessage createBytesMessage(byte[] bytesArrayBody)
                                throws JMSException
Creates a GSBytesMessageImpl object. A BytesMessage object is used to send a message containing a stream of uninterpreted bytes. This method is used in MessageConsumer.recieve() when the JMSMessageID is known already.

Parameters:
bytesArrayBody -
Throws:
JMSException - if the JMS provider fails to create this message due to some internal error.
IllegalStateException - If the session is closed.
See Also:
Session.createBytesMessage()

createMapMessage

public MapMessage createMapMessage()
                            throws JMSException
Creates a GSMapMessageImpl object. A GSMapMessageImpl object is used to send a self-defining set of name-value pairs, where names are String objects and values are primitive values in the Java programming language.

Specified by:
createMapMessage in interface Session
Throws:
JMSException - if the JMS provider fails to create this message due to some internal error.
IllegalStateException - If the session is closed.
See Also:
Session.createMapMessage()

createMessage

public Message createMessage()
                      throws JMSException
Specified by:
createMessage in interface Session
Throws:
IllegalStateException - If the session is closed.
JMSException
See Also:
Session.createMessage()

createObjectMessage

public ObjectMessage createObjectMessage()
                                  throws JMSException
Creates a GSObjectMessageImpl object. A GSObjectMessageImpl object is used to send a Serializable java object.

Specified by:
createObjectMessage in interface Session
Throws:
IllegalStateException - If the session is closed.
JMSException
See Also:
Session.createObjectMessage()

createObjectMessage

public ObjectMessage createObjectMessage(Serializable object)
                                  throws JMSException
Creates a GSObjectMessageImpl object. A GSObjectMessageImpl object is used to send a Serializable java object.

Specified by:
createObjectMessage in interface Session
Parameters:
object -
Throws:
IllegalStateException - If the session is closed.
JMSException
See Also:
Session.createObjectMessage(java.io.Serializable)

createStreamMessage

public StreamMessage createStreamMessage()
                                  throws JMSException
Creates a StreamMessage object. A StreamMessage object is used to send a self-defining stream of primitive values in the Java programming language.

Specified by:
createStreamMessage in interface Session
Throws:
IllegalStateException - If the session is closed.
JMSException
See Also:
Session.createStreamMessage()

createTextMessage

public TextMessage createTextMessage()
                              throws JMSException
Creates an initialized TextMessage object. A TextMessage object is used to send a message containing a String.

Specified by:
createTextMessage in interface Session
Throws:
JMSException - if the JMS provider fails to create this message due to some internal error.
IllegalStateException - If the session is closed.
See Also:
Session.createTextMessage()

createTextMessage

public TextMessage createTextMessage(String text)
                              throws JMSException
Creates an initialized TextMessage object. A TextMessage object is used to send a message containing a String.

Specified by:
createTextMessage in interface Session
Parameters:
text - the string used to initialize this message
Throws:
JMSException - if the JMS provider fails to create this message due to some internal error.
IllegalStateException - If the session is closed.
See Also:
Session.createTextMessage(java.lang.String)

getTransacted

public boolean getTransacted()
                      throws JMSException
Specified by:
getTransacted in interface Session
Returns:
true if the session is transacted.
Throws:
JMSException
See Also:
Session.getTransacted()

getAcknowledgeMode

public int getAcknowledgeMode()
                       throws IllegalStateException
JMS 1.1 API

Specified by:
getAcknowledgeMode in interface Session
Returns:
m_acknowledgeMode
Throws:
IllegalStateException
See Also:
Session.getAcknowledgeMode()

commit

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

Specified by:
commit in interface Session
Throws:
IllegalStateException - If the session is m_closed or it is NOT transacted
JMSException
See Also:
Session.commit()

rollback

public void rollback()
              throws JMSException
API method for m_tx rollback Calling the space LocalTransactionManager m_tx.abort()

Specified by:
rollback in interface Session
Throws:
IllegalStateException - If the session is closed.
JMSException
See Also:
Session.rollback()

recover

public void recover()
             throws JMSException
Specified by:
recover in interface Session
Throws:
JMSException
See Also:
Session.recover()

close

public void close()
           throws JMSException
Specified by:
close in interface Session
Throws:
JMSException
See Also:
Session.close()

getMessageListener

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

setMessageListener

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

run

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

createProducer

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

createConsumer

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

createConsumer

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

createConsumer

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

getSessionID

public String getSessionID()
Returns:
String m_sessionID

setSessionID

public void setSessionID(String string)
Parameters:
string -

getConsumersC

public int getConsumersC()

getMessagesC

public int getMessagesC()

getProducersC

public int getProducersC()

setConsumersC

public void setConsumersC(int i)

setMessagesC

public void setMessagesC(int i)

setProducersC

public void setProducersC(int i)

toString

public String toString()
Overrides:
toString in class Object

getNumOfConsumedMsg

public int getNumOfConsumedMsg()
Returns:
m_numOfConsumedMsg

getNumOfProducedMsg

public int getNumOfProducedMsg()
Returns:
m_numOfProducedMsg

unsubscribe

public void unsubscribe(String subscriptionName)
                 throws JMSException
Currently not supported.

Specified by:
unsubscribe in interface Session
Specified by:
unsubscribe in interface TopicSession
Throws:
JMSException
See Also:
Session.unsubscribe(String)

createDurableSubscriber

public TopicSubscriber createDurableSubscriber(Topic topic,
                                               String name,
                                               String messageSelector,
                                               boolean noLocal)
                                        throws JMSException
Currently not supported.

Specified by:
createDurableSubscriber in interface Session
Specified by:
createDurableSubscriber in interface TopicSession
Throws:
JMSException
See Also:
Session.createDurableSubscriber(Topic, String, String, boolean)

createDurableSubscriber

public TopicSubscriber createDurableSubscriber(Topic topic,
                                               String name)
                                        throws JMSException
Currently not supported.

Specified by:
createDurableSubscriber in interface Session
Specified by:
createDurableSubscriber in interface TopicSession
Throws:
JMSException
See Also:
Session.createDurableSubscriber(Topic, String)

createTemporaryTopic

public TemporaryTopic createTemporaryTopic()
                                    throws JMSException
Creates a TemporaryTopic object. Its lifetime will be that of the TopicConnection unless it is deleted earlier. 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 m_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:
createTemporaryTopic in interface Session
Specified by:
createTemporaryTopic in interface TopicSession
Throws:
JMSException
See Also:
Session.createTemporaryQueue()

createTopic

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

createQueue

public Queue createQueue(String queueName)
                  throws JMSException
Specified by:
createQueue in interface QueueSession
Specified by:
createQueue in interface Session
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
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
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
Throws:
JMSException
See Also:
Session.createTemporaryQueue()

createPublisher

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

createSubscriber

public TopicSubscriber createSubscriber(Topic topic)
                                 throws JMSException
Specified by:
createSubscriber in interface TopicSession
Throws:
JMSException
See Also:
TopicSession.createSubscriber(Topic)

createSubscriber

public TopicSubscriber createSubscriber(Topic topic,
                                        String messageSelector,
                                        boolean noLocal)
                                 throws JMSException
Specified by:
createSubscriber in interface TopicSession
Throws:
JMSException
See Also:
TopicSession.createSubscriber(Topic, String, boolean)

createReceiver

public QueueReceiver createReceiver(Queue queue)
                             throws JMSException
Specified by:
createReceiver in interface QueueSession
Throws:
JMSException
See Also:
QueueSession.createReceiver(Queue)

createReceiver

public QueueReceiver createReceiver(Queue queue,
                                    String messageSelector)
                             throws JMSException
Specified by:
createReceiver in interface QueueSession
Throws:
JMSException
See Also:
QueueSession.createReceiver(Queue, String)

createSender

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