public class GSSessionImpl extends Object implements javax.jms.Session, javax.jms.TopicSession, javax.jms.QueueSession, Runnable
javax.jms.Session
interface. Limitations:
-
Sessions support only a single MessageConsumer
.
- Durable subscribers are not
supported. - StreamMessage is not supported.
Session
Modifier and Type | Field and Description |
---|---|
protected Transaction |
_tx |
protected Vector<GSQueueBrowserImpl> |
m_browsers
Maintains a list of m_browsers for the session.
|
protected boolean |
m_closed
true if the session is closed. |
protected boolean |
m_closing
If true, indicates that the session is in the process of being closed
|
protected Map<String,GSMessageConsumerImpl> |
m_consumers
Maintains a list of m_consumers for the session.
|
protected boolean |
m_isQueue |
protected Vector<GSMessageProducerImpl> |
m_producers
Maintains a list of m_producers for the session.
|
protected boolean |
m_stopped
This flag determines whether message delivery is enabled or disabled.
|
protected LinkedList<GSMessageImpl> |
sentMessages
Holds the messages produced and sent by this session during a transaction.
|
static long |
txLeaseTime |
protected LinkedList<com.j_spaces.jms.GSSessionImpl.MessageQueueElement> |
unackedMessages
Holds the messages consumed consumers during a transaction and were not acked.
|
Constructor and Description |
---|
GSSessionImpl(com.j_spaces.jms.GSConnectionImpl conn,
boolean isTransacted,
int acknowledgeMode)
Creates a session.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addBrowser(GSQueueBrowserImpl browser) |
protected void |
addConsumer(GSMessageConsumerImpl consumer) |
protected void |
addProducer(GSMessageProducerImpl producer) |
void |
close() |
void |
commit()
Commits all messages done in this transaction and releases any locks currently held.
|
javax.jms.QueueBrowser |
createBrowser(javax.jms.Queue queue) |
javax.jms.QueueBrowser |
createBrowser(javax.jms.Queue queue,
String messageSelector) |
javax.jms.BytesMessage |
createBytesMessage()
Creates a
GSBytesMessageImpl object. |
javax.jms.BytesMessage |
createBytesMessage(byte[] bytesArrayBody)
Creates a
GSBytesMessageImpl object. |
javax.jms.MessageConsumer |
createConsumer(javax.jms.Destination destination) |
javax.jms.MessageConsumer |
createConsumer(javax.jms.Destination destination,
String messageSelector) |
javax.jms.MessageConsumer |
createConsumer(javax.jms.Destination destination,
String messageSelector,
boolean noLocal) |
javax.jms.TopicSubscriber |
createDurableSubscriber(javax.jms.Topic topic,
String name)
Currently not supported.
|
javax.jms.TopicSubscriber |
createDurableSubscriber(javax.jms.Topic topic,
String name,
String messageSelector,
boolean noLocal)
Currently not supported.
|
javax.jms.MapMessage |
createMapMessage()
Creates a
GSMapMessageImpl object. |
javax.jms.Message |
createMessage() |
javax.jms.ObjectMessage |
createObjectMessage()
Creates a
GSObjectMessageImpl object. |
javax.jms.ObjectMessage |
createObjectMessage(Serializable object)
Creates a
GSObjectMessageImpl object. |
javax.jms.MessageProducer |
createProducer(javax.jms.Destination destination) |
javax.jms.TopicPublisher |
createPublisher(javax.jms.Topic topic) |
javax.jms.Queue |
createQueue(String queueName) |
javax.jms.QueueReceiver |
createReceiver(javax.jms.Queue queue) |
javax.jms.QueueReceiver |
createReceiver(javax.jms.Queue queue,
String messageSelector) |
javax.jms.QueueSender |
createSender(javax.jms.Queue queue) |
javax.jms.StreamMessage |
createStreamMessage()
Creates a
StreamMessage object. |
javax.jms.TopicSubscriber |
createSubscriber(javax.jms.Topic topic) |
javax.jms.TopicSubscriber |
createSubscriber(javax.jms.Topic topic,
String messageSelector,
boolean noLocal) |
javax.jms.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'.
|
javax.jms.TemporaryTopic |
createTemporaryTopic()
Creates a
TemporaryTopic object. |
javax.jms.TextMessage |
createTextMessage()
Creates an initialized
TextMessage object. |
javax.jms.TextMessage |
createTextMessage(String text)
Creates an initialized
TextMessage object. |
javax.jms.Topic |
createTopic(String topicName) |
protected void |
ensureTX()
Verifies that the session is under TX
|
int |
getAcknowledgeMode()
JMS 1.1 API
|
protected com.j_spaces.jms.GSConnectionImpl |
getConn() |
int |
getConsumersC() |
String |
getJMSProviderName() |
javax.jms.MessageListener |
getMessageListener() |
int |
getMessagesC() |
int |
getNumOfConsumedMsg() |
int |
getNumOfProducedMsg() |
int |
getProducersC() |
protected int |
getRandomInt() |
String |
getSessionID() |
boolean |
getTransacted() |
protected Transaction |
getTransaction() |
protected boolean |
isClosed()
Check if the session is closed
|
void |
recover() |
protected void |
removeBrower(GSQueueBrowserImpl browser) |
protected void |
removeConsumer(GSMessageConsumerImpl consumer) |
protected void |
removeProducer(GSMessageProducerImpl producer) |
void |
rollback() |
void |
run() |
void |
setConsumersC(int i) |
void |
setMessageListener(javax.jms.MessageListener listener) |
void |
setMessagesC(int i) |
void |
setProducersC(int i) |
void |
setSessionID(String string) |
String |
toString() |
void |
unsubscribe(String subscriptionName)
Currently not supported.
|
protected volatile boolean m_closed
true
if the session is closed.protected volatile boolean m_closing
protected volatile boolean m_stopped
protected Map<String,GSMessageConsumerImpl> m_consumers
protected Vector<GSMessageProducerImpl> m_producers
protected Vector<GSQueueBrowserImpl> m_browsers
protected Transaction _tx
public static final long txLeaseTime
protected LinkedList<GSMessageImpl> sentMessages
protected LinkedList<com.j_spaces.jms.GSSessionImpl.MessageQueueElement> unackedMessages
protected boolean m_isQueue
public GSSessionImpl(com.j_spaces.jms.GSConnectionImpl conn, boolean isTransacted, int acknowledgeMode) throws javax.jms.JMSException
conn
- The connection the session belongs to.isTransacted
- true
for a transacted session.acknowledgeMode
- 1 (auto), 2 (client) or 3 (dups ok).javax.jms.JMSException
- In case of an invalid acknowledge mode.public String getJMSProviderName()
public javax.jms.BytesMessage createBytesMessage() throws javax.jms.JMSException
GSBytesMessageImpl
object. A BytesMessage
object is used
to send a message containing a stream of uninterpreted bytes.createBytesMessage
in interface javax.jms.Session
javax.jms.JMSException
- if the JMS provider fails to create this message due to some
internal error.javax.jms.IllegalStateException
- If the session is closed.Session.createBytesMessage()
public javax.jms.BytesMessage createBytesMessage(byte[] bytesArrayBody) throws javax.jms.JMSException
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.javax.jms.JMSException
- if the JMS provider fails to create this message due to some
internal error.javax.jms.IllegalStateException
- If the session is closed.Session.createBytesMessage()
public javax.jms.MapMessage createMapMessage() throws javax.jms.JMSException
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.createMapMessage
in interface javax.jms.Session
javax.jms.JMSException
- if the JMS provider fails to create this message due to some
internal error.javax.jms.IllegalStateException
- If the session is closed.Session.createMapMessage()
public javax.jms.Message createMessage() throws javax.jms.JMSException
createMessage
in interface javax.jms.Session
javax.jms.IllegalStateException
- If the session is closed.javax.jms.JMSException
Session.createMessage()
public javax.jms.ObjectMessage createObjectMessage() throws javax.jms.JMSException
GSObjectMessageImpl
object. A GSObjectMessageImpl
object
is used to send a Serializable java object.createObjectMessage
in interface javax.jms.Session
javax.jms.IllegalStateException
- If the session is closed.javax.jms.JMSException
Session.createObjectMessage()
public javax.jms.ObjectMessage createObjectMessage(Serializable object) throws javax.jms.JMSException
GSObjectMessageImpl
object. A GSObjectMessageImpl
object
is used to send a Serializable java object.createObjectMessage
in interface javax.jms.Session
javax.jms.IllegalStateException
- If the session is closed.javax.jms.JMSException
Session.createObjectMessage(Serializable)
public javax.jms.StreamMessage createStreamMessage() throws javax.jms.JMSException
StreamMessage
object. A StreamMessage
object is used to
send a self-defining stream of primitive values in the Java programming language.createStreamMessage
in interface javax.jms.Session
javax.jms.IllegalStateException
- If the session is closed.javax.jms.JMSException
Session.createStreamMessage()
public javax.jms.TextMessage createTextMessage() throws javax.jms.JMSException
TextMessage
object. A TextMessage
object is
used to send a message containing a String
.createTextMessage
in interface javax.jms.Session
javax.jms.JMSException
- if the JMS provider fails to create this message due to some
internal error.javax.jms.IllegalStateException
- If the session is closed.Session.createTextMessage()
public javax.jms.TextMessage createTextMessage(String text) throws javax.jms.JMSException
TextMessage
object. A TextMessage
object is
used to send a message containing a String
.createTextMessage
in interface javax.jms.Session
text
- the string used to initialize this messagejavax.jms.JMSException
- if the JMS provider fails to create this message due to some
internal error.javax.jms.IllegalStateException
- If the session is closed.Session.createTextMessage(String)
public boolean getTransacted() throws javax.jms.JMSException
getTransacted
in interface javax.jms.Session
javax.jms.JMSException
Session.getTransacted()
protected Transaction getTransaction()
public int getAcknowledgeMode() throws javax.jms.IllegalStateException
getAcknowledgeMode
in interface javax.jms.Session
javax.jms.IllegalStateException
Session.getAcknowledgeMode()
public void commit() throws javax.jms.JMSException
commit
in interface javax.jms.Session
javax.jms.IllegalStateException
- If the session is m_closed or it is NOT transactedjavax.jms.JMSException
Session.commit()
public void rollback() throws javax.jms.JMSException
rollback
in interface javax.jms.Session
javax.jms.JMSException
public void recover() throws javax.jms.JMSException
recover
in interface javax.jms.Session
javax.jms.JMSException
Session.recover()
public void close() throws javax.jms.JMSException
close
in interface javax.jms.Session
javax.jms.JMSException
Session.close()
protected void ensureTX() throws javax.jms.IllegalStateException
javax.jms.IllegalStateException
- if the session is not under txpublic javax.jms.MessageListener getMessageListener() throws javax.jms.JMSException
getMessageListener
in interface javax.jms.Session
javax.jms.JMSException
public void setMessageListener(javax.jms.MessageListener listener) throws javax.jms.JMSException
setMessageListener
in interface javax.jms.Session
javax.jms.JMSException
public void run()
public javax.jms.MessageProducer createProducer(javax.jms.Destination destination) throws javax.jms.JMSException
createProducer
in interface javax.jms.Session
javax.jms.JMSException
Session.createProducer(Destination)
public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination) throws javax.jms.JMSException
createConsumer
in interface javax.jms.Session
javax.jms.JMSException
Session.createConsumer(Destination)
public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, String messageSelector) throws javax.jms.JMSException
createConsumer
in interface javax.jms.Session
javax.jms.JMSException
Session.createConsumer(Destination, String)
public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, String messageSelector, boolean noLocal) throws javax.jms.JMSException
createConsumer
in interface javax.jms.Session
javax.jms.JMSException
Session.createConsumer(Destination, String, boolean)
public String getSessionID()
public void setSessionID(String string)
string
- protected int getRandomInt()
public int getConsumersC()
public int getMessagesC()
public int getProducersC()
public void setConsumersC(int i)
public void setMessagesC(int i)
public void setProducersC(int i)
public int getNumOfConsumedMsg()
public int getNumOfProducedMsg()
protected void addConsumer(GSMessageConsumerImpl consumer)
protected void removeConsumer(GSMessageConsumerImpl consumer)
protected void addProducer(GSMessageProducerImpl producer)
protected void removeProducer(GSMessageProducerImpl producer)
protected final boolean isClosed()
true
if the session is m_closedprotected com.j_spaces.jms.GSConnectionImpl getConn()
public void unsubscribe(String subscriptionName) throws javax.jms.JMSException
unsubscribe
in interface javax.jms.Session
unsubscribe
in interface javax.jms.TopicSession
javax.jms.JMSException
Session.unsubscribe(String)
public javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic, String name, String messageSelector, boolean noLocal) throws javax.jms.JMSException
createDurableSubscriber
in interface javax.jms.Session
createDurableSubscriber
in interface javax.jms.TopicSession
javax.jms.JMSException
Session.createDurableSubscriber(Topic, String, String, boolean)
public javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic, String name) throws javax.jms.JMSException
createDurableSubscriber
in interface javax.jms.Session
createDurableSubscriber
in interface javax.jms.TopicSession
javax.jms.JMSException
Session.createDurableSubscriber(Topic, String)
public javax.jms.TemporaryTopic createTemporaryTopic() throws javax.jms.JMSException
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.createTemporaryTopic
in interface javax.jms.Session
createTemporaryTopic
in interface javax.jms.TopicSession
javax.jms.JMSException
Session.createTemporaryQueue()
public javax.jms.Topic createTopic(String topicName) throws javax.jms.JMSException
createTopic
in interface javax.jms.Session
createTopic
in interface javax.jms.TopicSession
javax.jms.JMSException
Session.createTopic(String)
public javax.jms.Queue createQueue(String queueName) throws javax.jms.JMSException
createQueue
in interface javax.jms.QueueSession
createQueue
in interface javax.jms.Session
javax.jms.JMSException
Session.createQueue(String)
public javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue) throws javax.jms.JMSException
createBrowser
in interface javax.jms.QueueSession
createBrowser
in interface javax.jms.Session
javax.jms.JMSException
Session.createBrowser(Queue)
public javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue, String messageSelector) throws javax.jms.JMSException
createBrowser
in interface javax.jms.QueueSession
createBrowser
in interface javax.jms.Session
javax.jms.JMSException
Session.createBrowser(Queue, String)
protected void addBrowser(GSQueueBrowserImpl browser)
protected void removeBrower(GSQueueBrowserImpl browser)
public javax.jms.TemporaryQueue createTemporaryQueue() throws javax.jms.JMSException
createTemporaryQueue
in interface javax.jms.QueueSession
createTemporaryQueue
in interface javax.jms.Session
javax.jms.JMSException
Session.createTemporaryQueue()
public javax.jms.TopicPublisher createPublisher(javax.jms.Topic topic) throws javax.jms.JMSException
createPublisher
in interface javax.jms.TopicSession
javax.jms.JMSException
TopicSession.createPublisher(Topic)
public javax.jms.TopicSubscriber createSubscriber(javax.jms.Topic topic) throws javax.jms.JMSException
createSubscriber
in interface javax.jms.TopicSession
javax.jms.JMSException
TopicSession.createSubscriber(Topic)
public javax.jms.TopicSubscriber createSubscriber(javax.jms.Topic topic, String messageSelector, boolean noLocal) throws javax.jms.JMSException
createSubscriber
in interface javax.jms.TopicSession
javax.jms.JMSException
TopicSession.createSubscriber(Topic, String, boolean)
public javax.jms.QueueReceiver createReceiver(javax.jms.Queue queue) throws javax.jms.JMSException
createReceiver
in interface javax.jms.QueueSession
javax.jms.JMSException
QueueSession.createReceiver(Queue)
public javax.jms.QueueReceiver createReceiver(javax.jms.Queue queue, String messageSelector) throws javax.jms.JMSException
createReceiver
in interface javax.jms.QueueSession
javax.jms.JMSException
QueueSession.createReceiver(Queue, String)
public javax.jms.QueueSender createSender(javax.jms.Queue queue) throws javax.jms.JMSException
createSender
in interface javax.jms.QueueSession
javax.jms.JMSException
QueueSession.createSender(Queue)
Copyright © GigaSpaces.