Class WmSessionImpl
- java.lang.Object
-
- com.webmethods.locks.Node
-
- com.webmethods.jms.impl.WmSessionImpl
-
- All Implemented Interfaces:
WmSession
,java.lang.Runnable
,javax.jms.Session
- Direct Known Subclasses:
WmClusterSessionImpl
,WmQueueSessionImpl
,WmTopicSessionImpl
,WmXASessionImpl
public class WmSessionImpl extends Node implements WmSession
This implementation need not be thread safe, which means the assumption of only 1 user thread ever in this class holds good.However, care should be taken that when connection.close() is called, the session.close() is called only when the session is done with its inflight job.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
WmSessionImpl.SessionDispatcher
Class for dispatch of asynchronous message delivery.
-
Field Summary
Fields Modifier and Type Field Description protected int
_acknowledgeMode
protected boolean
_closed
protected boolean
_closeInProgress
WmConnectionImpl
_connection
protected WmMessageImpl
_currentAsyncMessage
protected boolean
_isXA
protected boolean
_logApi
protected java.util.Vector<WmMessageConsumer>
_messageConsumers
protected javax.jms.MessageListener
_messageListener
protected java.util.Vector<WmMessageProducer>
_messageProducers
protected WmSessionQueue
_messageQueue
protected java.util.List<WmMessageConsumerImpl>
_newMessageListeners
protected WmSessionImpl.SessionDispatcher
_sessionDispatcher
protected int
_sessionDispatcherCount
protected boolean
_sessionReconnect
protected java.util.Vector<WmMessageConsumer>
_sessionSubscriberMessageConsumers
protected boolean
_transacted
protected long
_transactionID
protected int
_transactionTimeout
protected WmXid
_xid
protected java.lang.String
brokerName
static int
DEFAULT_TRANSACTION_TIMEOUT
-
Fields inherited from class com.webmethods.locks.Node
_lockManager
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
WmSessionImpl(WmConnectionImpl connection)
Default constructor for subclasses.protected
WmSessionImpl(WmConnectionImpl connection, boolean transacted, boolean isXA, int acknowledgeMode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMessageConsumer(WmMessageConsumerImpl messageConsumer)
protected void
addMessageProducer(WmMessageProducerImpl messageProducer)
void
addMessageToQueue(WmMessageImpl message)
Adds the message into the message queue.void
addSessionSubscriberMessageConsumer(WmMessageConsumer messageConsumer)
protected void
checkCreateConsumer(javax.jms.Destination destination)
protected void
checkCreateDurableConsumer(javax.jms.Destination destination)
protected void
checkCreateProducer(javax.jms.Destination destination)
protected void
checkForClusteringSupport(javax.jms.MessageConsumer consumer, javax.jms.Destination destination)
protected void
checkState()
void
close()
Closes the session.protected void
closeMessageConsumers()
protected void
closeMessageProducers()
void
commit()
Commits all messages done in this transaction and releases any locks currently held.javax.jms.QueueBrowser
createBrowser(javax.jms.Queue queue)
Creates aQueueBrowser
object to peek at the messages on the specified queue.javax.jms.QueueBrowser
createBrowser(javax.jms.Queue queue, java.lang.String messageSelector)
Creates aQueueBrowser
object to peek at the messages on the specified queue using a message selector.javax.jms.BytesMessage
createBytesMessage()
Creates aBytesMessage
object.javax.jms.MessageConsumer
createConsumer(javax.jms.Destination destination)
Creates aMessageConsumer
for the specified destination.javax.jms.MessageConsumer
createConsumer(javax.jms.Destination destination, java.lang.String messageSelector)
Creates aMessageConsumer
for the specified destination, using a message selector.javax.jms.MessageConsumer
createConsumer(javax.jms.Destination destination, java.lang.String messageSelector, boolean noLocal)
CreatesMessageConsumer
for the specified destination, using a message selector.javax.jms.TopicSubscriber
createDurableSubscriber(javax.jms.Topic topic, java.lang.String name)
Creates a durable subscriber to the specified topic.javax.jms.TopicSubscriber
createDurableSubscriber(javax.jms.Topic topic, java.lang.String name, java.lang.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.WmFileMessage
createFileMessage()
Creates aWmFileMessage
object.javax.jms.MapMessage
createMapMessage()
Creates aMapMessage
object.javax.jms.Message
createMessage()
Creates aMessage
object.javax.jms.ObjectMessage
createObjectMessage()
Creates anObjectMessage
object.javax.jms.ObjectMessage
createObjectMessage(java.io.Serializable object)
Creates an initializedObjectMessage
object.javax.jms.MessageProducer
createProducer(javax.jms.Destination destination)
Creates aMessageProducer
to send messages to the specified destination.javax.jms.TopicPublisher
createPublisher(javax.jms.Topic topic)
Creates a publisher for the specified topic.javax.jms.Queue
createQueue(java.lang.String queueName)
Creates a queue identity given aQueue
name.protected WmQueueBrowserImpl
createQueueBrowserImpl(WmQueueImpl queue, java.lang.String messageSelector)
Creates a queue implementation instance.javax.jms.QueueReceiver
createReceiver(javax.jms.Queue queue)
Creates aQueueReceiver
object to receive messages from the specified queue.javax.jms.QueueReceiver
createReceiver(javax.jms.Queue queue, java.lang.String messageSelector)
Creates aQueueReceiver
object to receive messages from the specified queue using a message selector.javax.jms.QueueSender
createSender(javax.jms.Queue queue)
Creates aQueueSender
object to send messages to the specified queue.javax.jms.StreamMessage
createStreamMessage()
Creates aStreamMessage
object.javax.jms.TopicSubscriber
createSubscriber(javax.jms.Topic topic)
Creates a nondurable subscriber to the specified topic.javax.jms.TopicSubscriber
createSubscriber(javax.jms.Topic topic, java.lang.String messageSelector, boolean noLocal)
Creates a nondurable subscriber to the specified topic, using a message selector or specifying whether messages published by its own connection should be delivered to it.javax.jms.TemporaryQueue
createTemporaryQueue()
Creates aTemporaryQueue
object.javax.jms.TemporaryQueue
createTemporaryQueue(java.lang.String queueName)
javax.jms.TemporaryTopic
createTemporaryTopic()
Creates aTemporaryTopic
object.javax.jms.TextMessage
createTextMessage()
Creates aTextMessage
object.javax.jms.TextMessage
createTextMessage(java.lang.String text)
Creates an initializedTextMessage
object.javax.jms.Topic
createTopic(java.lang.String topicName)
Creates a topic identity given aTopic
name.WmSessionQueue
get_messageQueue()
long
get_transactionID()
int
getAcknowledgeMode()
Returns the acknowledgement mode of the session.java.lang.String
getBrokerName()
Gets the underlying broker nameWmConnection
getConnection()
Returns the connection used to create this session.protected WmTopicSubscriberImpl
getDurableSubscriber(java.lang.String name)
javax.jms.ExceptionListener
getExceptionListener()
Gets theExceptionListener
object for this session.java.util.Vector<WmMessageConsumer>
getMessageConsumers()
javax.jms.MessageListener
getMessageListener()
Returns the session's distinguished message listener (optional).long
getSessionDispatcherThreadID()
Used for clustering.protected java.lang.String
getTemporaryQueueName(java.lang.String clientID)
protected java.lang.String
getTemporaryTopicName(java.lang.String clientID)
boolean
getTransacted()
Indicates whether the session is in transacted mode.protected void
invokeExceptionListener(java.lang.Exception exception)
boolean
isTransacted()
int
prepare(long xid)
int
prepare(long xid, boolean isCluster)
Prepare Transaction for Clustervoid
publish(WmMessageImpl[] messages, int deliveryMode, boolean deliver)
void
publish(WmMessageImpl message, int deliveryMode, boolean deliver)
void
recover()
Stops message delivery in this session, and restarts message delivery with the oldest unacknowledged message.void
recoverInternal(boolean recoverFromSessionDispatcher)
void
removeMessageConsumer(WmMessageConsumerImpl messageConsumer)
protected void
removeMessageProducer(WmMessageProducerImpl messageProducer)
void
removeSessionSubscriberMessageConsumer(WmMessageConsumer messageConsumer)
void
rollback()
Rolls back any messages done in this transaction and releases any locks currently held.void
run()
Optional operation, intended to be used only by Application Servers, not by ordinary JMS clients.void
sessionAcknowledge()
void
sessionAcknowledgeInternal(java.lang.Thread sessionThread)
Acknowledge all received but unacknowledged messages on this session.void
setCurrentAsynMessage(WmMessageImpl message)
Sets the current async message, which will be included in the transaction.void
setExceptionListener(javax.jms.ExceptionListener listener)
Sets an exception listener for this session.void
setMessageListener(WmMessageConsumerImpl consumer, javax.jms.MessageListener listener)
A message listener has been added to a message consumer.void
setMessageListener(javax.jms.MessageListener listener)
Sets the session's distinguished message listener (optional).void
setMessageQueue(WmSessionQueue queue)
Added to change the implementation of the WmSessionQueue to the WmClusterSessionQueueImpl incase of cluster sessionsvoid
start()
Starts synchronous and asynchronous message delivery.void
stop()
Stops synchronous and asynchronous message delivery.java.lang.String
toString()
void
unsubscribe(java.lang.String name)
Unsubscribes a durable subscription that has been created by a client.void
unsubscribe(java.lang.String name, boolean force)
Unsubscribes a durable subscription that has been created by a client.protected boolean
validAcknowledgeMode(int acknowledgeMode)
Validates an acknowledge mode.-
Methods inherited from class com.webmethods.locks.Node
getLockManager, getParent
-
-
-
-
Field Detail
-
_connection
public WmConnectionImpl _connection
-
_messageQueue
protected WmSessionQueue _messageQueue
-
_currentAsyncMessage
protected volatile WmMessageImpl _currentAsyncMessage
-
_isXA
protected boolean _isXA
-
_logApi
protected boolean _logApi
-
_transacted
protected boolean _transacted
-
_closed
protected volatile boolean _closed
-
_closeInProgress
protected volatile boolean _closeInProgress
-
_transactionID
protected volatile long _transactionID
-
DEFAULT_TRANSACTION_TIMEOUT
public static final int DEFAULT_TRANSACTION_TIMEOUT
- See Also:
- Constant Field Values
-
_transactionTimeout
protected int _transactionTimeout
-
_xid
protected volatile WmXid _xid
-
_sessionDispatcher
protected WmSessionImpl.SessionDispatcher _sessionDispatcher
-
_sessionDispatcherCount
protected int _sessionDispatcherCount
-
_messageListener
protected javax.jms.MessageListener _messageListener
-
_messageProducers
protected java.util.Vector<WmMessageProducer> _messageProducers
-
_messageConsumers
protected java.util.Vector<WmMessageConsumer> _messageConsumers
-
_sessionSubscriberMessageConsumers
protected java.util.Vector<WmMessageConsumer> _sessionSubscriberMessageConsumers
-
_newMessageListeners
protected java.util.List<WmMessageConsumerImpl> _newMessageListeners
-
_acknowledgeMode
protected int _acknowledgeMode
-
_sessionReconnect
protected boolean _sessionReconnect
-
brokerName
protected java.lang.String brokerName
-
-
Constructor Detail
-
WmSessionImpl
protected WmSessionImpl(WmConnectionImpl connection, boolean transacted, boolean isXA, int acknowledgeMode) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
WmSessionImpl
protected WmSessionImpl(WmConnectionImpl connection)
Default constructor for subclasses.
-
-
Method Detail
-
setMessageQueue
public void setMessageQueue(WmSessionQueue queue)
Added to change the implementation of the WmSessionQueue to the WmClusterSessionQueueImpl incase of cluster sessions- Parameters:
queue
-
-
createBytesMessage
public javax.jms.BytesMessage createBytesMessage() throws javax.jms.JMSException
Creates aBytesMessage
object. ABytesMessage
object is used to send a message containing a stream of uninterpreted bytes.- Specified by:
createBytesMessage
in interfacejavax.jms.Session
- Throws:
javax.jms.JMSException
- if the JMS provider fails to create this message due to some internal error.
-
createMapMessage
public javax.jms.MapMessage createMapMessage() throws javax.jms.JMSException
Creates aMapMessage
object. AMapMessage
object is used to send a self-defining set of name-value pairs, where names areString
objects and values are primitive values in the Java programming language.- Specified by:
createMapMessage
in interfacejavax.jms.Session
- Throws:
javax.jms.JMSException
- if the JMS provider fails to create this message due to some internal error.
-
createMessage
public javax.jms.Message createMessage() throws javax.jms.JMSException
Creates aMessage
object. TheMessage
interface is the root interface of all JMS messages. AMessage
object holds all the standard message header information. It can be sent when a message containing only header information is sufficient.- Specified by:
createMessage
in interfacejavax.jms.Session
- Throws:
javax.jms.JMSException
- if the JMS provider fails to create this message due to some internal error.
-
createObjectMessage
public javax.jms.ObjectMessage createObjectMessage() throws javax.jms.JMSException
Creates anObjectMessage
object. AnObjectMessage
object is used to send a message that contains a serializable Java object.- Specified by:
createObjectMessage
in interfacejavax.jms.Session
- Throws:
javax.jms.JMSException
- if the JMS provider fails to create this message due to some internal error.
-
createObjectMessage
public javax.jms.ObjectMessage createObjectMessage(java.io.Serializable object) throws javax.jms.JMSException
Creates an initializedObjectMessage
object. AnObjectMessage
object is used to send a message that contains a serializable Java object.- Specified by:
createObjectMessage
in interfacejavax.jms.Session
- Parameters:
object
- the object to use to initialize this message- Throws:
javax.jms.JMSException
- if the JMS provider fails to create this message due to some internal error.
-
createStreamMessage
public javax.jms.StreamMessage createStreamMessage() throws javax.jms.JMSException
Creates aStreamMessage
object. AStreamMessage
object is used to send a self-defining stream of primitive values in the Java programming language.- Specified by:
createStreamMessage
in interfacejavax.jms.Session
- Throws:
javax.jms.JMSException
- if the JMS provider fails to create this message due to some internal error.
-
createTextMessage
public javax.jms.TextMessage createTextMessage() throws javax.jms.JMSException
Creates aTextMessage
object. ATextMessage
object is used to send a message containing aString
object.- Specified by:
createTextMessage
in interfacejavax.jms.Session
- Throws:
javax.jms.JMSException
- if the JMS provider fails to create this message due to some internal error.
-
createTextMessage
public javax.jms.TextMessage createTextMessage(java.lang.String text) throws javax.jms.JMSException
Creates an initializedTextMessage
object. ATextMessage
object is used to send a message containing aString
.- Specified by:
createTextMessage
in interfacejavax.jms.Session
- Parameters:
text
- the string used to initialize this message- Throws:
javax.jms.JMSException
- if the JMS provider fails to create this message due to some internal error.
-
getTransacted
public boolean getTransacted() throws javax.jms.JMSException
Indicates whether the session is in transacted mode.- Specified by:
getTransacted
in interfacejavax.jms.Session
- Returns:
- true if the session is in transacted mode
- Throws:
javax.jms.JMSException
- if the JMS provider fails to return the transaction mode due to some internal error.
-
getAcknowledgeMode
public int getAcknowledgeMode() throws javax.jms.JMSException
Returns the acknowledgement mode of the session. The acknowledgement mode is set at the time that the session is created. If the session is transacted, the acknowledgement mode is ignored.- Specified by:
getAcknowledgeMode
in interfacejavax.jms.Session
- Returns:
- If the session is not transacted, returns the current acknowledgement mode for the session. If the session is transacted, returns SESSION_TRANSACTED.
- Throws:
javax.jms.JMSException
- if the JMS provider fails to return the acknowledgment mode due to some internal error.
-
commit
public void commit() throws javax.jms.JMSException
Commits all messages done in this transaction and releases any locks currently held.- Specified by:
commit
in interfacejavax.jms.Session
- Throws:
javax.jms.JMSException
- if the JMS provider fails to commit the transaction due to some internal error.javax.jms.TransactionRolledBackException
- if the transaction is rolled back due to some internal error during commit.javax.jms.IllegalStateException
- if the method is not called by a transacted session.
-
prepare
public int prepare(long xid) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
prepare
public int prepare(long xid, boolean isCluster) throws javax.jms.JMSException
Prepare Transaction for Cluster- Parameters:
xid
-isCluster
-- Throws:
javax.jms.JMSException
-
rollback
public void rollback() throws javax.jms.JMSException
Rolls back any messages done in this transaction and releases any locks currently held.- Specified by:
rollback
in interfacejavax.jms.Session
- Throws:
javax.jms.JMSException
- if the JMS provider fails to roll back the transaction due to some internal error.javax.jms.IllegalStateException
- if the method is not called by a transacted session.
-
close
public void close() throws javax.jms.JMSException
Closes the session.Since a provider may allocate some resources on behalf of a session outside the JVM, clients should close the resources when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough.
There is no need to close the producers and consumers of a closed session.
This call will block until a
receive
call or message listener in progress has completed. A blocked message consumerreceive
call returnsnull
when this session is closed.Closing a transacted session must roll back the transaction in progress.
This method is the only
Session
method that can be called concurrently.Invoking any other
Session
method on a closed session must throw aJMSException.IllegalStateException
. Closing a closed session must not throw an exception.- Specified by:
close
in interfacejavax.jms.Session
- Throws:
javax.jms.JMSException
- if the JMS provider fails to close the session due to some internal error.
-
recover
public void recover() throws javax.jms.JMSException
Stops message delivery in this session, and restarts message delivery with the oldest unacknowledged message.All consumers deliver messages in a serial order. Acknowledging a received message automatically acknowledges all messages that have been delivered to the client.
Restarting a session causes it to take the following actions:
- Stop message delivery
- Mark all messages that might have been delivered but not acknowledged as "redelivered"
- Restart the delivery sequence including all unacknowledged messages that had been previously delivered. Redelivered messages do not have to be delivered in exactly their original delivery order.
- Specified by:
recover
in interfacejavax.jms.Session
- Throws:
javax.jms.JMSException
- if the JMS provider fails to stop and restart message delivery due to some internal error.javax.jms.IllegalStateException
- if the method is called by a transacted session.
-
recoverInternal
public void recoverInternal(boolean recoverFromSessionDispatcher) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
getMessageListener
public javax.jms.MessageListener getMessageListener() throws javax.jms.JMSException
Returns the session's distinguished message listener (optional).- Specified by:
getMessageListener
in interfacejavax.jms.Session
- Returns:
- the message listener associated with this session
- Throws:
javax.jms.JMSException
- if the JMS provider fails to get the message listener due to an internal error.
-
setMessageListener
public void setMessageListener(javax.jms.MessageListener listener) throws javax.jms.JMSException
Sets the session's distinguished message listener (optional).When the distinguished message listener is set, no other form of message receipt in the session can be used; however, all forms of sending messages are still supported.
This is an expert facility not used by regular JMS clients.
- Specified by:
setMessageListener
in interfacejavax.jms.Session
- Parameters:
listener
- the message listener to associate with this session- Throws:
javax.jms.JMSException
- if the JMS provider fails to set the message listener due to an internal error.
-
run
public void run()
Optional operation, intended to be used only by Application Servers, not by ordinary JMS clients.- Specified by:
run
in interfacejava.lang.Runnable
- Specified by:
run
in interfacejavax.jms.Session
-
createProducer
public javax.jms.MessageProducer createProducer(javax.jms.Destination destination) throws javax.jms.JMSException
Creates aMessageProducer
to send messages to the specified destination.A client uses a
MessageProducer
object to send messages to a destination. SinceQueue
andTopic
both inherit fromDestination
, they can be used in the destination parameter to create aMessageProducer
object.- Specified by:
createProducer
in interfacejavax.jms.Session
- Parameters:
destination
- theDestination
to send to, or null if this is a producer which does not have a specified destination.- Throws:
javax.jms.JMSException
- if the session fails to create a MessageProducer due to some internal error.javax.jms.InvalidDestinationException
- if an invalid destination is specified.
-
createSender
public javax.jms.QueueSender createSender(javax.jms.Queue queue) throws javax.jms.JMSException
Creates aQueueSender
object to send messages to the specified queue.- Parameters:
queue
- theQueue
to access, or null if this is an unidentified producer- Throws:
javax.jms.JMSException
- if the session fails to create a sender due to some internal error.javax.jms.InvalidDestinationException
- if an invalid queue is specified.
-
createPublisher
public javax.jms.TopicPublisher createPublisher(javax.jms.Topic topic) throws javax.jms.JMSException
Creates a publisher for the specified topic.A client uses a
TopicPublisher
object to publish messages on a topic. Each time a client creates aTopicPublisher
on a topic, it defines a new sequence of messages that have no ordering relationship with the messages it has previously sent.- Parameters:
topic
- theTopic
to publish to, or null if this is an unidentified producer- Throws:
javax.jms.JMSException
- if the session fails to create a publisher due to some internal error.javax.jms.InvalidDestinationException
- if an invalid topic is specified.
-
createConsumer
public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination) throws javax.jms.JMSException
Creates aMessageConsumer
for the specified destination. SinceQueue
andTopic
both inherit fromDestination
, they can be used in the destination parameter to create aMessageConsumer
.- Specified by:
createConsumer
in interfacejavax.jms.Session
- Parameters:
destination
- theDestination
to access.- Throws:
javax.jms.JMSException
- if the session fails to create a consumer due to some internal error.javax.jms.InvalidDestinationException
- if an invalid destination is specified.
-
createConsumer
public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, java.lang.String messageSelector) throws javax.jms.JMSException
Creates aMessageConsumer
for the specified destination, using a message selector. SinceQueue
andTopic
both inherit fromDestination
, they can be used in the destination parameter to create aMessageConsumer
.A client uses a
MessageConsumer
object to receive messages that have been sent to a destination.- Specified by:
createConsumer
in interfacejavax.jms.Session
- Parameters:
destination
- theDestination
to accessmessageSelector
- 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:
javax.jms.JMSException
- if the session fails to create a MessageConsumer due to some internal error.javax.jms.InvalidDestinationException
- if an invalid destination is specified.javax.jms.InvalidSelectorException
- if the message selector is invalid.
-
createConsumer
public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, java.lang.String messageSelector, boolean noLocal) throws javax.jms.JMSException
CreatesMessageConsumer
for the specified destination, using a message selector. This method can specify whether messages published by its own connection should be delivered to it, if the destination is a topic.Since
Queue
andTopic
both inherit fromDestination
, they can be used in the destination parameter to create aMessageConsumer
.A client uses a
MessageConsumer
object to receive messages that have been published to a destination.In some cases, a connection may both publish and subscribe to a topic. The consumer
noLocal
attribute allows a consumer to inhibit the delivery of messages published by its own connection. The default value for this attribute is False. ThenoLocal
value must be supported by destinations that are topics.- Specified by:
createConsumer
in interfacejavax.jms.Session
- Parameters:
destination
- theDestination
to accessmessageSelector
- 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 true, and the destination is a topic, inhibits the delivery of messages published by its own connection. The behavior fornoLocal
is not specified if the destination is a queue.- Throws:
javax.jms.JMSException
- if the session fails to create a MessageConsumer due to some internal error.javax.jms.InvalidDestinationException
- if an invalid destination is specified.javax.jms.InvalidSelectorException
- if the message selector is invalid.
-
createQueue
public javax.jms.Queue createQueue(java.lang.String queueName) throws javax.jms.JMSException
Creates a queue identity given aQueue
name.This facility is provided for the rare cases where clients need to dynamically manipulate queue identity. It allows the creation of a queue 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 queue. The physical creation of queues is an administrative task and is not to be initiated by the JMS API. The one exception is the creation of temporary queues, which is accomplished with the
createTemporaryQueue
method.- Specified by:
createQueue
in interfacejavax.jms.Session
- Parameters:
queueName
- the name of thisQueue
- Returns:
- a
Queue
with the given name - Throws:
javax.jms.JMSException
- if the session fails to create a queue due to some internal error.
-
createTopic
public javax.jms.Topic createTopic(java.lang.String topicName) throws javax.jms.JMSException
Creates a topic identity given aTopic
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 interfacejavax.jms.Session
- Parameters:
topicName
- the name of thisTopic
- Returns:
- a
Topic
with the given name - Throws:
javax.jms.JMSException
- if the session fails to create a topic due to some internal error.
-
createSubscriber
public javax.jms.TopicSubscriber createSubscriber(javax.jms.Topic topic) throws javax.jms.JMSException
Creates a nondurable subscriber to the specified topic.A client uses a
TopicSubscriber
object to receive messages that have been published to a topic.Regular
TopicSubscriber
objects are not durable. They receive only messages that are published while they are active.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.- Parameters:
topic
- theTopic
to subscribe to- Throws:
javax.jms.JMSException
- if the session fails to create a subscriber due to some internal error.javax.jms.InvalidDestinationException
- if an invalid topic is specified.
-
createSubscriber
public javax.jms.TopicSubscriber createSubscriber(javax.jms.Topic topic, java.lang.String messageSelector, boolean noLocal) throws javax.jms.JMSException
Creates a nondurable subscriber to the specified topic, using a message selector or specifying whether messages published by its own connection should be delivered to it.A client uses a
TopicSubscriber
object to receive messages that have been published to a topic.Regular
TopicSubscriber
objects are not durable. They receive only messages that are published while they are active.Messages filtered out by a subscriber's message selector will never be delivered to the subscriber. From the subscriber's perspective, they do not exist.
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.- Parameters:
topic
- theTopic
to subscribe tomessageSelector
- 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:
javax.jms.JMSException
- if the session fails to create a subscriber due to some internal error.javax.jms.InvalidDestinationException
- if an invalid topic is specified.javax.jms.InvalidSelectorException
- if the message selector is invalid.
-
createDurableSubscriber
public javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic, java.lang.String name) throws javax.jms.JMSException
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 interfacejavax.jms.Session
- Parameters:
topic
- the non-temporaryTopic
to subscribe toname
- the name used to identify this subscription- Throws:
javax.jms.JMSException
- if the session fails to create a subscriber due to some internal error.javax.jms.InvalidDestinationException
- if an invalid topic is specified.
-
createDurableSubscriber
public javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic, java.lang.String name, java.lang.String messageSelector, boolean noLocal) throws javax.jms.JMSException
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 interfacejavax.jms.Session
- Parameters:
topic
- the non-temporaryTopic
to subscribe toname
- the name used to identify this subscriptionmessageSelector
- 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:
javax.jms.JMSException
- if the session fails to create a subscriber due to some internal error.javax.jms.InvalidDestinationException
- if an invalid topic is specified.javax.jms.InvalidSelectorException
- if the message selector is invalid.
-
createReceiver
public javax.jms.QueueReceiver createReceiver(javax.jms.Queue queue) throws javax.jms.JMSException
Creates aQueueReceiver
object to receive messages from the specified queue.- Parameters:
queue
- theQueue
to access- Throws:
javax.jms.JMSException
- if the session fails to create a receiver due to some internal error.javax.jms.InvalidDestinationException
- if an invalid queue is specified.
-
createReceiver
public javax.jms.QueueReceiver createReceiver(javax.jms.Queue queue, java.lang.String messageSelector) throws javax.jms.JMSException
Creates aQueueReceiver
object to receive messages from the specified queue using a message selector.- Parameters:
queue
- theQueue
to accessmessageSelector
- 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:
javax.jms.JMSException
- if the session fails to create a receiver due to some internal error.javax.jms.InvalidDestinationException
- if an invalid queue is specified.javax.jms.InvalidSelectorException
- if the message selector is invalid.
-
createBrowser
public javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue) throws javax.jms.JMSException
Creates aQueueBrowser
object to peek at the messages on the specified queue.- Specified by:
createBrowser
in interfacejavax.jms.Session
- Parameters:
queue
- thequeue
to access- Throws:
javax.jms.JMSException
- if the session fails to create a browser due to some internal error.javax.jms.InvalidDestinationException
- if an invalid destination is specified
-
createBrowser
public javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue, java.lang.String messageSelector) throws javax.jms.JMSException
Creates aQueueBrowser
object to peek at the messages on the specified queue using a message selector.- Specified by:
createBrowser
in interfacejavax.jms.Session
- Parameters:
queue
- thequeue
to accessmessageSelector
- 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:
javax.jms.JMSException
- if the session fails to create a browser due to some internal error.javax.jms.InvalidDestinationException
- if an invalid destination is specifiedjavax.jms.InvalidSelectorException
- if the message selector is invalid.
-
createQueueBrowserImpl
protected WmQueueBrowserImpl createQueueBrowserImpl(WmQueueImpl queue, java.lang.String messageSelector) throws javax.jms.JMSException
Creates a queue implementation instance.- Parameters:
queue
-messageSelector
-- Throws:
javax.jms.JMSException
-
createTemporaryQueue
public javax.jms.TemporaryQueue createTemporaryQueue() throws javax.jms.JMSException
Creates aTemporaryQueue
object. Its lifetime will be that of theConnection
unless it is deleted earlier.- Specified by:
createTemporaryQueue
in interfacejavax.jms.Session
- Returns:
- a temporary queue identity
- Throws:
javax.jms.JMSException
- if the session fails to create a temporary queue due to some internal error.
-
getTemporaryQueueName
protected java.lang.String getTemporaryQueueName(java.lang.String clientID)
-
createTemporaryQueue
public javax.jms.TemporaryQueue createTemporaryQueue(java.lang.String queueName) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
createTemporaryTopic
public javax.jms.TemporaryTopic createTemporaryTopic() throws javax.jms.JMSException
Creates aTemporaryTopic
object. Its lifetime will be that of theConnection
unless it is deleted earlier.- Specified by:
createTemporaryTopic
in interfacejavax.jms.Session
- Returns:
- a temporary topic identity
- Throws:
javax.jms.JMSException
- if the session fails to create a temporary topic due to some internal error.
-
getTemporaryTopicName
protected java.lang.String getTemporaryTopicName(java.lang.String clientID)
-
unsubscribe
public void unsubscribe(java.lang.String name) throws javax.jms.JMSException
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
orTopicSubscriber
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 interfacejavax.jms.Session
- Parameters:
name
- the name used to identify this subscription- Throws:
javax.jms.JMSException
- if the session fails to unsubscribe to the durable subscription due to some internal error.javax.jms.InvalidDestinationException
- if an invalid subscription name is specified.
-
unsubscribe
public void unsubscribe(java.lang.String name, boolean force) throws javax.jms.JMSException
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.
- Parameters:
name
- the name used to identify this subscriptionforce
-true
to forcibly unsubscribe even if the subscriber has consumed messages that are a part of the pending transaction or has not been acknowledged in the session- Throws:
javax.jms.JMSException
- if the session fails to unsubscribe to the durable subscription due to some internal error.javax.jms.InvalidDestinationException
- if an invalid subscription name is specified.
-
getConnection
public WmConnection getConnection() throws javax.jms.JMSException
Returns the connection used to create this session.- Returns:
- the connection used to create his session
- Throws:
javax.jms.JMSException
- if the JMS provider fails to get the connection for this session.
-
getExceptionListener
public javax.jms.ExceptionListener getExceptionListener() throws javax.jms.JMSException
Gets theExceptionListener
object for this session.- Specified by:
getExceptionListener
in interfaceWmSession
- Returns:
- the
ExceptionListener
for this session, or null. if noExceptionListener
is associated with this session. - Throws:
javax.jms.JMSException
- if the JMS provider fails to get theExceptionListener
for this session.- See Also:
setExceptionListener(javax.jms.ExceptionListener)
-
setExceptionListener
public void setExceptionListener(javax.jms.ExceptionListener listener) throws javax.jms.JMSException
Sets an exception listener for this session.If an exception is thrown by a user-defined MessageListener's run() method from one of the session's MessageConsumers, it informs the sessions's
ExceptionListener
, if one has been registered. It does this by calling the listener'sonException
method, passing it aJMSException
object with a linked exception containing the exception thrown by the MessageListener's run() method.- Specified by:
setExceptionListener
in interfaceWmSession
- Parameters:
listener
- the exception listener- Throws:
javax.jms.JMSException
- if the JMS provider fails to set the exception listener for this session.- See Also:
getExceptionListener()
-
createFileMessage
public WmFileMessage createFileMessage() throws javax.jms.JMSException
Description copied from interface:WmSession
Creates aWmFileMessage
object. AWmFileMessage
object is used to stream a file that is to large to load into memory.- Specified by:
createFileMessage
in interfaceWmSession
- Throws:
javax.jms.JMSException
- if the JMS provider fails to create this message due to some internal error.
-
invokeExceptionListener
protected void invokeExceptionListener(java.lang.Exception exception)
-
checkState
protected void checkState() throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
checkCreateConsumer
protected void checkCreateConsumer(javax.jms.Destination destination) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
checkCreateProducer
protected void checkCreateProducer(javax.jms.Destination destination) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
checkCreateDurableConsumer
protected void checkCreateDurableConsumer(javax.jms.Destination destination) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
checkForClusteringSupport
protected void checkForClusteringSupport(javax.jms.MessageConsumer consumer, javax.jms.Destination destination) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
start
public void start() throws javax.jms.JMSException
Starts synchronous and asynchronous message delivery. Called byConnection.start()
.- Throws:
javax.jms.JMSException
-
stop
public void stop() throws javax.jms.JMSException
Stops synchronous and asynchronous message delivery. Called byConnection.stop()
.- Throws:
javax.jms.JMSException
-
addMessageConsumer
public void addMessageConsumer(WmMessageConsumerImpl messageConsumer)
-
addSessionSubscriberMessageConsumer
public void addSessionSubscriberMessageConsumer(WmMessageConsumer messageConsumer)
-
removeMessageConsumer
public void removeMessageConsumer(WmMessageConsumerImpl messageConsumer)
-
removeSessionSubscriberMessageConsumer
public void removeSessionSubscriberMessageConsumer(WmMessageConsumer messageConsumer)
-
closeMessageConsumers
protected void closeMessageConsumers() throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
getDurableSubscriber
protected WmTopicSubscriberImpl getDurableSubscriber(java.lang.String name)
-
addMessageProducer
protected void addMessageProducer(WmMessageProducerImpl messageProducer)
-
removeMessageProducer
protected void removeMessageProducer(WmMessageProducerImpl messageProducer)
-
closeMessageProducers
protected void closeMessageProducers() throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
publish
public void publish(WmMessageImpl message, int deliveryMode, boolean deliver) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
publish
public void publish(WmMessageImpl[] messages, int deliveryMode, boolean deliver) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
sessionAcknowledge
public void sessionAcknowledge() throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
sessionAcknowledgeInternal
public void sessionAcknowledgeInternal(java.lang.Thread sessionThread) throws javax.jms.JMSException
Acknowledge all received but unacknowledged messages on this session. Only takes effect if the session is in CLIENT_ACKNOWLEDGE acknowledgement mode. Called byWmMessageImpl.acknowledge()
.- Throws:
javax.jms.JMSException
-
setMessageListener
public void setMessageListener(WmMessageConsumerImpl consumer, javax.jms.MessageListener listener)
A message listener has been added to a message consumer. Wake up the session's dispatcher so that any messages received synchronously can now be processed asynchronously.
-
validAcknowledgeMode
protected boolean validAcknowledgeMode(int acknowledgeMode)
Validates an acknowledge mode.- Parameters:
acknowledgeMode
- the acknowledge mode to validate- Returns:
true
if the acknowledge mode is valid,false
otherwise
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
get_transactionID
public long get_transactionID()
-
getBrokerName
public java.lang.String getBrokerName() throws javax.jms.JMSException
Gets the underlying broker name- Throws:
javax.jms.JMSException
-
getMessageConsumers
public java.util.Vector<WmMessageConsumer> getMessageConsumers()
-
isTransacted
public boolean isTransacted()
-
getSessionDispatcherThreadID
public long getSessionDispatcherThreadID()
Used for clustering.
-
get_messageQueue
public WmSessionQueue get_messageQueue()
-
addMessageToQueue
public void addMessageToQueue(WmMessageImpl message)
Adds the message into the message queue.- Parameters:
message
-
-
setCurrentAsynMessage
public void setCurrentAsynMessage(WmMessageImpl message)
Sets the current async message, which will be included in the transaction. Is called from within the ASF APIs.- Parameters:
message
-
-
-