com.j_spaces.jms
Class GSXAConnectionImpl

java.lang.Object
  extended by com.j_spaces.jms.GSXAConnectionImpl
All Implemented Interfaces:
Connection, QueueConnection, TopicConnection, XAConnection, XAQueueConnection, XATopicConnection
Direct Known Subclasses:
GSXAQueueConnectionImpl, GSXATopicConnectionImpl

public class GSXAConnectionImpl
extends Object
implements XAConnection, XATopicConnection, XAQueueConnection

GigaSpaces implemention of the javax.jms.XAConnection interface.


Constructor Summary
GSXAConnectionImpl(GSXAConnectionFactoryImpl factory)
          Create an instance of GSXAConnectionImpl.
 
Method Summary
 void close()
          API method for closing the connection; even if the connection appears to be broken, closes the sessions.
 ConnectionConsumer createConnectionConsumer(Destination destination, String messageSelector, ServerSessionPool sessionPool, int maxMessages)
           
 ConnectionConsumer createConnectionConsumer(Queue queue, String messageSelector, ServerSessionPool sessionPool, int maxMessages)
           
 ConnectionConsumer createConnectionConsumer(Topic topic, String messageSelector, ServerSessionPool sessionPool, int maxMessages)
           
 ConnectionConsumer createDurableConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool, int maxMessages)
           
 QueueSession createQueueSession(boolean transacted, int acknowledgeMode)
           
 Session createSession(boolean transacted, int acknowledgeMode)
          Use the extended methods, from GSTopicConnectionImpl for Topic and from GSQueueConnectionImpl for Queue.
 TopicSession createTopicSession(boolean transacted, int acknowledgeMode)
           
 XAQueueSession createXAQueueSession()
           
 XASession createXASession()
           
 XATopicSession createXATopicSession()
           
 String getClientID()
          The connection client ID contains the space name together with the Destination name, "space name_destination name" e.g.
 int getCompressionMinSize()
           
 ExceptionListener getExceptionListener()
           
 ConnectionMetaData getMetaData()
           
 Transaction getTransaction(boolean localTransaction, long leaseTime)
          create a new local transaction instance and use it in case of a transacted JMS session.
 void setClientID(String clientID)
          The connection client ID contains the random connection Key + hostname + space name + destination name "space name_destination name" e.g.
 void setExceptionListener(ExceptionListener listener)
           
 void start()
          Overwrite of the API method for starting the Topic connection.
 void stop()
          Overwrite of the API method for stoping the Topic connection.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.jms.XAConnection
createSession
 
Methods inherited from interface javax.jms.Connection
close, createConnectionConsumer, getClientID, getExceptionListener, getMetaData, setClientID, setExceptionListener, start, stop
 
Methods inherited from interface javax.jms.XATopicConnection
createTopicSession
 
Methods inherited from interface javax.jms.XAConnection
createSession
 
Methods inherited from interface javax.jms.Connection
close, createConnectionConsumer, getClientID, getExceptionListener, getMetaData, setClientID, setExceptionListener, start, stop
 
Methods inherited from interface javax.jms.TopicConnection
createConnectionConsumer, createDurableConnectionConsumer
 
Methods inherited from interface javax.jms.Connection
close, createConnectionConsumer, getClientID, getExceptionListener, getMetaData, setClientID, setExceptionListener, start, stop
 
Methods inherited from interface javax.jms.XAQueueConnection
createQueueSession
 
Methods inherited from interface javax.jms.XAConnection
createSession
 
Methods inherited from interface javax.jms.Connection
close, createConnectionConsumer, getClientID, getExceptionListener, getMetaData, setClientID, setExceptionListener, start, stop
 
Methods inherited from interface javax.jms.QueueConnection
createConnectionConsumer
 
Methods inherited from interface javax.jms.Connection
close, createConnectionConsumer, getClientID, getExceptionListener, getMetaData, setClientID, setExceptionListener, start, stop
 

Constructor Detail

GSXAConnectionImpl

public GSXAConnectionImpl(GSXAConnectionFactoryImpl factory)
                   throws JMSException
Create an instance of GSXAConnectionImpl.

Parameters:
factory - parent factory.
Throws:
JMSException - if failed to create connection.
Method Detail

createXASession

public XASession createXASession()
                          throws JMSException
Specified by:
createXASession in interface XAConnection
Throws:
JMSException
See Also:
XAConnection.createXASession()

createXATopicSession

public XATopicSession createXATopicSession()
                                    throws JMSException
Specified by:
createXATopicSession in interface XATopicConnection
Throws:
JMSException
See Also:
XATopicConnection.createXATopicSession()

createXAQueueSession

public XAQueueSession createXAQueueSession()
                                    throws JMSException
Specified by:
createXAQueueSession in interface XAQueueConnection
Throws:
JMSException
See Also:
XAQueueConnection.createXAQueueSession()

createSession

public Session createSession(boolean transacted,
                             int acknowledgeMode)
                      throws JMSException
Use the extended methods, from GSTopicConnectionImpl for Topic and from GSQueueConnectionImpl for Queue.

Specified by:
createSession in interface Connection
Returns:
null
Throws:
JMSException
See Also:
Connection.createSession(boolean, int)

getClientID

public String getClientID()
                   throws JMSException
The connection client ID contains the space name together with the Destination name, "space name_destination name" e.g. "JavaSpaces_MyTopic"

Specified by:
getClientID in interface Connection
Returns:
String m_clientID
Throws:
JMSException
See Also:
Connection.getClientID()

setClientID

public void setClientID(String clientID)
                 throws JMSException
The connection client ID contains the random connection Key + hostname + space name + destination name "space name_destination name" e.g. "JavaSpaces_MyTopic" Client cannot set a clientID more then once.

Specified by:
setClientID in interface Connection
Parameters:
clientID -
Throws:
IllegalStateException
JMSException
See Also:
Connection.setClientID(java.lang.String)

getMetaData

public ConnectionMetaData getMetaData()
                               throws JMSException
Specified by:
getMetaData in interface Connection
Throws:
JMSException
See Also:
Connection.getMetaData(), GSConnectionMetaDataImpl

getExceptionListener

public ExceptionListener getExceptionListener()
                                       throws JMSException
Specified by:
getExceptionListener in interface Connection
Throws:
JMSException
See Also:
Connection.getExceptionListener()

setExceptionListener

public void setExceptionListener(ExceptionListener listener)
                          throws JMSException
Specified by:
setExceptionListener in interface Connection
Throws:
JMSException
See Also:
Connection.setExceptionListener(javax.jms.ExceptionListener)

start

public void start()
           throws JMSException
Overwrite of the API method for starting the Topic connection. Loops on all the sessions and starts them.

Specified by:
start in interface Connection
Throws:
IllegalStateException - If the connection is closed or broken.
JMSException

stop

public void stop()
          throws JMSException
Overwrite of the API method for stoping the Topic connection.

Specified by:
stop in interface Connection
Throws:
IllegalStateException - If the connection is closed or broken.
JMSException
See Also:
Connection.stop()

close

public void close()
           throws JMSException
API method for closing the connection; even if the connection appears to be broken, closes the sessions. Loops on all the sessions and closes them. If one or more of the connection�s session�s message listeners is processing a message at the point when connection close is invoked, all the facilities of the connection and its sessions must remain available to those listeners until they return control to the JMS provider. When connection close is invoked it should not return until message processing has been shut down in an orderly fashion. This means that all message listeners that may have been running have returned, and that all pending receives have returned.

Specified by:
close in interface Connection
Throws:
JMSException - Actually never thrown.

createConnectionConsumer

public ConnectionConsumer createConnectionConsumer(Destination destination,
                                                   String messageSelector,
                                                   ServerSessionPool sessionPool,
                                                   int maxMessages)
                                            throws JMSException
Specified by:
createConnectionConsumer in interface Connection
Throws:
JMSException
See Also:
Connection.createConnectionConsumer(javax.jms.Destination, java.lang.String, javax.jms.ServerSessionPool, int)

createDurableConnectionConsumer

public ConnectionConsumer createDurableConnectionConsumer(Topic topic,
                                                          String subscriptionName,
                                                          String messageSelector,
                                                          ServerSessionPool sessionPool,
                                                          int maxMessages)
                                                   throws JMSException
Specified by:
createDurableConnectionConsumer in interface Connection
Specified by:
createDurableConnectionConsumer in interface TopicConnection
Throws:
JMSException
See Also:
Connection.createDurableConnectionConsumer(javax.jms.Topic, java.lang.String, java.lang.String, javax.jms.ServerSessionPool, int)

getTransaction

public Transaction getTransaction(boolean localTransaction,
                                  long leaseTime)
                           throws com.j_spaces.jms.TransactionCreateException
create a new local transaction instance and use it in case of a transacted JMS session.

Parameters:
leaseTime -
Returns:
tr
Throws:
JMSException
com.j_spaces.jms.TransactionCreateException

toString

public String toString()
Overrides:
toString in class Object

getCompressionMinSize

public int getCompressionMinSize()
Returns:
Returns the compressionMinSize. The minimum size (in bytes) which from where we start to compress all the message body. e.g. if a 1 MB Text JMSMessage body is sent, and the compressionMinSize value is 500000 (0.5MB) then we will compress that message body (only), otherwise we will send (write) it as is. TODO Currently this configured via system property later will be part of the JMS-config.xml default value is 0.5 MB

createConnectionConsumer

public ConnectionConsumer createConnectionConsumer(Queue queue,
                                                   String messageSelector,
                                                   ServerSessionPool sessionPool,
                                                   int maxMessages)
                                            throws JMSException
Specified by:
createConnectionConsumer in interface QueueConnection
Throws:
JMSException
See Also:
QueueConnection.createConnectionConsumer(Queue, String, ServerSessionPool, int)

createQueueSession

public QueueSession createQueueSession(boolean transacted,
                                       int acknowledgeMode)
                                throws JMSException
Specified by:
createQueueSession in interface QueueConnection
Throws:
JMSException
See Also:
QueueConnection.createQueueSession(boolean, int)

createConnectionConsumer

public ConnectionConsumer createConnectionConsumer(Topic topic,
                                                   String messageSelector,
                                                   ServerSessionPool sessionPool,
                                                   int maxMessages)
                                            throws JMSException
Specified by:
createConnectionConsumer in interface TopicConnection
Throws:
JMSException
See Also:
TopicConnection.createConnectionConsumer(Topic, String, ServerSessionPool, int)

createTopicSession

public TopicSession createTopicSession(boolean transacted,
                                       int acknowledgeMode)
                                throws JMSException
Specified by:
createTopicSession in interface TopicConnection
Throws:
JMSException
See Also:
TopicConnection.createTopicSession(boolean, int)