org.exolab.jms.client
Class JmsXATopicSession

java.lang.Object
  |
  +--org.exolab.jms.client.JmsSession
        |
        +--org.exolab.jms.client.JmsTopicSession
              |
              +--org.exolab.jms.client.JmsXATopicSession
All Implemented Interfaces:
JmsMessageListener, MessageSessionIfc, java.lang.Runnable, javax.jms.Session, javax.jms.TopicSession, javax.jms.XASession, javax.jms.XATopicSession

public class JmsXATopicSession
extends org.exolab.jms.client.JmsTopicSession
implements javax.jms.XATopicSession

Client implementation of the javax.jms.XATopicSession interface

Version:
$Revision: 1.2 $ $Date: 2005/03/18 03:36:37 $
Author:
Jim Alateras, Tim Anderson

Fields inherited from interface javax.jms.Session
AUTO_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, SESSION_TRANSACTED
 
Method Summary
 void acknowledgeMessage(javax.jms.Message message)
          Acknowledge the specified message.
protected  void addConsumer(org.exolab.jms.client.JmsMessageConsumer consumer)
          Add a consumer to the list of consumers managed by this session.
protected  void addMessage(javax.jms.Message message)
          Add a message to the message cache.
protected  void addProducer(org.exolab.jms.client.JmsMessageProducer producer)
          Add a producer to the list of producers managed by this session.
protected  long allocateConsumer(javax.jms.Destination destination, java.lang.String selector, boolean noLocal)
          Creates a new message consumer, returning its identity.
 java.util.List browse(long consumerId, int count)
          Browse up to count messages.
protected  boolean checkForValidTemporaryDestination(JmsDestination destination)
          This method checks the destination.
 void close()
          Close the session.
 void commit()
          Throws a TransactionInProgressException, since it should not be called for an XASession object.
 javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue)
          Creates a QueueBrowser object to peek at the messages on the specified queue.
 javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue, java.lang.String messageSelector)
          This implementation always throws IllegalStateException, as per section 4.11 of the JMS specification.
 javax.jms.BytesMessage createBytesMessage()
          Creates a BytesMessage object.
 javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination)
          Creates a MessageConsumer for the specified destination.
 javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, java.lang.String messageSelector)
          Creates a MessageProducer to receive messages from the specified destination, matching particular selection criteria
 javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, java.lang.String messageSelector, boolean noLocal)
          Creates a MessageConsumer to receive messages from the specified destination, matching particular selection criteria.
 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.
 javax.jms.MapMessage createMapMessage()
          Creates a MapMessage object.
 javax.jms.Message createMessage()
          Creates a Message object.
 javax.jms.ObjectMessage createObjectMessage()
          Creates an ObjectMessage object.
 javax.jms.ObjectMessage createObjectMessage(java.io.Serializable object)
          Creates an initialized ObjectMessage object.
 javax.jms.MessageProducer createProducer(javax.jms.Destination destination)
          Creates a MessageProducer to send messages to the specified destination.
 javax.jms.TopicPublisher createPublisher(javax.jms.Topic topic)
          Create a publisher for the specified topic.
 javax.jms.Queue createQueue(java.lang.String queueName)
          This implementation always throws IllegalStateException, as per section 4.11 of the JMS specification
 javax.jms.StreamMessage createStreamMessage()
          Creates a StreamMessage object.
 javax.jms.TopicSubscriber createSubscriber(javax.jms.Topic topic)
          Create a non-durable subscriber for the specified topic.
 javax.jms.TopicSubscriber createSubscriber(javax.jms.Topic topic, java.lang.String selector, boolean noLocal)
          Create a non-durable subscriber for the specified topic.
 javax.jms.TemporaryQueue createTemporaryQueue()
          This implementation always throws IllegalStateException, as per section 4.11 of the JMS specification
 javax.jms.TemporaryTopic createTemporaryTopic()
          Creates a TemporaryTopic object.
 javax.jms.TextMessage createTextMessage()
          Creates a TextMessage object.
 javax.jms.TextMessage createTextMessage(java.lang.String text)
          Creates an initialized TextMessage object.
 javax.jms.Topic createTopic(java.lang.String topicName)
          Creates a topic identity given a Topic name.
protected  void ensureOpen()
          Verifies that the session isn't closed.
 int getAcknowledgeMode()
          Returns the acknowledgement mode of the session.
protected  org.exolab.jms.client.JmsConnection getConnection()
          Return a reference to the connection that created this session.
 javax.jms.MessageListener getMessageListener()
          Returns the message listener associated with the session
protected  ServerSession getServerSession()
          Returns the server session.
 javax.jms.Session getSession()
          Gets the session associated with this XASession.
 javax.jms.TopicSession getTopicSession()
          Gets the queue session associated with this XATopicSession.
 boolean getTransacted()
          Indicates whether the session is in transacted mode.
 javax.transaction.xa.XAResource getXAResource()
          Returns an XA resource to the caller.
protected  boolean isClosed()
          Check if the session is closed.
 boolean onMessage(MessageImpl message)
          Deliver a message.
 void onMessageAvailable()
          Inform the session that there is a message available for a synchronous consumer.
 MessageImpl receive(long consumerId, long timeout)
          Receive the next message that arrives within the specified timeout interval.
 MessageImpl receiveNoWait(long consumerId)
          Receive the next message if one is immediately available.
 void recover()
          Stop message delivery in this session, and restart sending messages with the oldest unacknowledged message
protected  void removeConsumer(org.exolab.jms.client.JmsMessageConsumer consumer)
          Remove a consumer, deregistering it on the server.
 void removeMessageListener(org.exolab.jms.client.JmsMessageConsumer listener)
          Remove a message listener
protected  void removeProducer(org.exolab.jms.client.JmsMessageProducer producer)
          Remove the producer from the list of managed producers.
 void rollback()
          Throws a TransactionInProgressException, since it should not be called for an XASession object.
 void run()
          Iterates through the list of messages added by an JmsConnectionConsumer, sending them to the registered listener
protected  void sendMessage(javax.jms.Message message)
          Send the specified message to the server.
 void setAsynchronous(long consumerId, boolean enable)
          Enable or disable asynchronous message delivery for the specified consumer.
 void setMessageListener(org.exolab.jms.client.JmsMessageConsumer listener)
          Set the message listener for a particular consumer.
 void setMessageListener(javax.jms.MessageListener listener)
          Sets the session's message listener.
 void start()
          This will start message delivery to this session.
 void stop()
          This will stop message delivery to this session.
 void unsubscribe(java.lang.String name)
          Unsubscribes a durable subscription that has been created by a client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.jms.Session
close, createBrowser, createBrowser, createBytesMessage, createConsumer, createConsumer, createConsumer, createDurableSubscriber, createDurableSubscriber, createMapMessage, createMessage, createObjectMessage, createObjectMessage, createProducer, createQueue, createStreamMessage, createTemporaryQueue, createTemporaryTopic, createTextMessage, createTextMessage, createTopic, getAcknowledgeMode, getMessageListener, recover, run, setMessageListener, unsubscribe
 
Methods inherited from interface javax.jms.TopicSession
createDurableSubscriber, createDurableSubscriber, createTemporaryTopic, createTopic, unsubscribe
 

Method Detail

getTopicSession

public javax.jms.TopicSession getTopicSession()
Gets the queue session associated with this XATopicSession.
Specified by:
getTopicSession in interface javax.jms.XATopicSession
Returns:
the queue session object

getSession

public javax.jms.Session getSession()
Gets the session associated with this XASession.
Specified by:
getSession in interface javax.jms.XASession
Returns:
the session object

getXAResource

public javax.transaction.xa.XAResource getXAResource()
Returns an XA resource to the caller.
Specified by:
getXAResource in interface javax.jms.XASession
Returns:
an XA resource to the caller

getTransacted

public boolean getTransacted()
Indicates whether the session is in transacted mode.
Specified by:
getTransacted in interface javax.jms.XASession
Overrides:
getTransacted in class org.exolab.jms.client.JmsSession
Returns:
true

commit

public void commit()
            throws javax.jms.JMSException
Throws a TransactionInProgressException, since it should not be called for an XASession object.
Specified by:
commit in interface javax.jms.XASession
Overrides:
commit in class org.exolab.jms.client.JmsSession
Throws:
javax.jms.TransactionInProgressException - if invoked

rollback

public void rollback()
              throws javax.jms.JMSException
Throws a TransactionInProgressException, since it should not be called for an XASession object.
Specified by:
rollback in interface javax.jms.XASession
Overrides:
rollback in class org.exolab.jms.client.JmsSession
Throws:
javax.jms.TransactionInProgressException - if invoked

createSubscriber

public javax.jms.TopicSubscriber createSubscriber(javax.jms.Topic topic)
                                           throws javax.jms.JMSException
Create a non-durable subscriber for the specified topic.
Specified by:
createSubscriber in interface javax.jms.TopicSession
Parameters:
topic - the topic to subscriber to
Returns:
the new subscriber
Throws:
javax.jms.JMSException - if the subscriber cannot be created

createSubscriber

public javax.jms.TopicSubscriber createSubscriber(javax.jms.Topic topic,
                                                  java.lang.String selector,
                                                  boolean noLocal)
                                           throws javax.jms.JMSException
Create a non-durable subscriber for the specified topic.
Specified by:
createSubscriber in interface javax.jms.TopicSession
Parameters:
topic - the topic to subscriber to
selector - the message selector to filter messages. May be null
noLocal - if true, inhibits the delivery of messages published by its own connection
Returns:
the new subscriber
Throws:
javax.jms.JMSException - if the subscriber cannot be created

createPublisher

public javax.jms.TopicPublisher createPublisher(javax.jms.Topic topic)
                                         throws javax.jms.JMSException
Create a publisher for the specified topic.
Specified by:
createPublisher in interface javax.jms.TopicSession
Parameters:
topic - the topic to publish to, or null if this is an unidentified producer
Returns:
the new publisher
Throws:
javax.jms.JMSException - if the publisher can't be created

createBrowser

public javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue,
                                            java.lang.String messageSelector)
                                     throws javax.jms.JMSException
This implementation always throws IllegalStateException, as per section 4.11 of the JMS specification.
Specified by:
createBrowser in interface javax.jms.Session
Overrides:
createBrowser in class org.exolab.jms.client.JmsSession
Throws:
java.lang.IllegalStateException - if invoked

createTemporaryQueue

public javax.jms.TemporaryQueue createTemporaryQueue()
                                              throws javax.jms.JMSException
This implementation always throws IllegalStateException, as per section 4.11 of the JMS specification
Specified by:
createTemporaryQueue in interface javax.jms.Session
Overrides:
createTemporaryQueue in class org.exolab.jms.client.JmsSession
Throws:
java.lang.IllegalStateException - if invoked.

createQueue

public javax.jms.Queue createQueue(java.lang.String queueName)
                            throws javax.jms.JMSException
This implementation always throws IllegalStateException, as per section 4.11 of the JMS specification
Specified by:
createQueue in interface javax.jms.Session
Overrides:
createQueue in class org.exolab.jms.client.JmsSession
Throws:
java.lang.IllegalStateException - if invoked.

createBytesMessage

public javax.jms.BytesMessage createBytesMessage()
                                          throws javax.jms.JMSException
Creates a BytesMessage object. A BytesMessage object is used to send a message containing a stream of uninterpreted bytes.
Specified by:
createBytesMessage in interface javax.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 a MapMessage object. A MapMessage 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 javax.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 a Message object. The Message interface is the root interface of all JMS messages. A Message 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 interface javax.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 an ObjectMessage object. An ObjectMessage object is used to send a message that contains a serializable Java object.
Specified by:
createObjectMessage in interface javax.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 initialized ObjectMessage object. An ObjectMessage object is used to send a message that contains a serializable Java object.
Specified by:
createObjectMessage in interface javax.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 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 javax.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 a TextMessage object. A TextMessage object is used to send a message containing a String object.
Specified by:
createTextMessage in interface javax.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 initialized TextMessage object. A TextMessage object is used to send a message containing a String.
Specified by:
createTextMessage in interface javax.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.

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 interface javax.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.
See Also:
Connection.createSession(boolean, int)

createProducer

public javax.jms.MessageProducer createProducer(javax.jms.Destination destination)
                                         throws javax.jms.JMSException
Creates a MessageProducer to send messages to the specified destination.
Specified by:
createProducer in interface javax.jms.Session
Parameters:
destination - the Destination 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.

createConsumer

public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination)
                                         throws javax.jms.JMSException
Creates a MessageConsumer for the specified destination.
Specified by:
createConsumer in interface javax.jms.Session
Parameters:
destination - the Destination 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 a MessageProducer to receive messages from the specified destination, matching particular selection criteria
Specified by:
createConsumer in interface javax.jms.Session
Parameters:
destination - the Destination to access
messageSelector - only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
Throws:
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
Creates a MessageConsumer to receive messages from the specified destination, matching particular selection criteria. This method can specify whether messages published by its own connection should be delivered to it, if the destination is a topic.

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. The noLocal value must be supported by destinations that are topics.

Specified by:
createConsumer in interface javax.jms.Session
Parameters:
destination - the Destination to access
messageSelector - only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
noLocal - if true, and the destination is a topic, inhibits the delivery of messages published by its own connection. The behavior for noLocal 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.

createTopic

public javax.jms.Topic createTopic(java.lang.String topicName)
                            throws javax.jms.JMSException
Creates a topic identity given a Topic 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 interface javax.jms.Session
Parameters:
topicName - the name of this Topic
Returns:
a Topic with the given name
Throws:
javax.jms.JMSException - if the session fails to create a topic due to some internal error.

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 interface javax.jms.Session
Parameters:
topic - the non-temporary Topic to subscribe to
name - 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 interface javax.jms.Session
Parameters:
topic - the non-temporary Topic to subscribe to
name - the name used to identify this subscription
messageSelector - only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
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.

createBrowser

public javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue)
                                     throws javax.jms.JMSException
Creates a QueueBrowser object to peek at the messages on the specified queue.
Specified by:
createBrowser in interface javax.jms.Session
Parameters:
queue - the queue 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

createTemporaryTopic

public javax.jms.TemporaryTopic createTemporaryTopic()
                                              throws javax.jms.JMSException
Creates a TemporaryTopic object. Its lifetime will be that of the Connection unless it is deleted earlier.
Specified by:
createTemporaryTopic in interface javax.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.

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 or TopicSubscriber 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 interface javax.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.

close

public void close()
           throws javax.jms.JMSException
Close the session. This call will block until a receive or message listener in progress has completed. A blocked message consumer receive call returns null when this session is closed.
Specified by:
close in interface javax.jms.Session
Throws:
javax.jms.JMSException - if the session can't be closed

recover

public void recover()
             throws javax.jms.JMSException
Stop message delivery in this session, and restart sending messages with the oldest unacknowledged message
Specified by:
recover in interface javax.jms.Session
Throws:
javax.jms.JMSException - if the session can't be recovered

getMessageListener

public javax.jms.MessageListener getMessageListener()
                                             throws javax.jms.JMSException
Returns the message listener associated with the session
Specified by:
getMessageListener in interface javax.jms.Session
Returns:
the message listener associated with the session, or null if no listener is registered
Throws:
javax.jms.JMSException - if the session is closed

setMessageListener

public void setMessageListener(javax.jms.MessageListener listener)
                        throws javax.jms.JMSException
Sets the session's message listener.
Specified by:
setMessageListener in interface javax.jms.Session
Parameters:
listener - the session's message listener
Throws:
javax.jms.JMSException - if the session is closed

run

public void run()
Iterates through the list of messages added by an JmsConnectionConsumer, sending them to the registered listener
Specified by:
run in interface javax.jms.Session

setMessageListener

public void setMessageListener(org.exolab.jms.client.JmsMessageConsumer listener)
                        throws javax.jms.JMSException
Set the message listener for a particular consumer.

If a listener is already registered for the consumer, it will be automatically overwritten

Parameters:
listener - the message listener
Throws:
javax.jms.JMSException - if the listener can't be set

removeMessageListener

public void removeMessageListener(org.exolab.jms.client.JmsMessageConsumer listener)
                           throws javax.jms.JMSException
Remove a message listener
Parameters:
listener - the message listener to remove
Throws:
javax.jms.JMSException - if the listener can't be removed

start

public void start()
           throws javax.jms.JMSException
This will start message delivery to this session. If message delivery has already started, or the session is currently being closed then this is a no-op.
Throws:
javax.jms.JMSException - if message delivery can't be started

stop

public void stop()
          throws javax.jms.JMSException
This will stop message delivery to this session. If message delivery has already stoped then this is a no-op.
Throws:
javax.jms.JMSException - if message delivery can't be stopped

acknowledgeMessage

public void acknowledgeMessage(javax.jms.Message message)
                        throws javax.jms.JMSException
Acknowledge the specified message. This is only applicable for CLIENT_ACKNOWLEDGE sessions. For other session types, the request is ignored.

Acking a message automatically acks all those that have come before it.

Specified by:
acknowledgeMessage in interface MessageSessionIfc
Parameters:
message - the message to acknowledge
Throws:
javax.jms.JMSException - if the message can't be acknowledged

setAsynchronous

public void setAsynchronous(long consumerId,
                            boolean enable)
                     throws javax.jms.JMSException
Enable or disable asynchronous message delivery for the specified consumer.
Parameters:
consumerId - the consumer identifier
enable - true to enable; false to disable
Throws:
javax.jms.JMSException - if message delivery cannot be enabled or disabled

onMessage

public boolean onMessage(MessageImpl message)
Deliver a message.
Specified by:
onMessage in interface JmsMessageListener
Parameters:
message - the message to deliver
Returns:
true if the message was delivered; otherwise false.

onMessageAvailable

public void onMessageAvailable()
Inform the session that there is a message available for a synchronous consumer.
Specified by:
onMessageAvailable in interface JmsMessageListener

receive

public MessageImpl receive(long consumerId,
                           long timeout)
                    throws javax.jms.JMSException
Receive the next message that arrives within the specified timeout interval. This call blocks until a message arrives, the timeout expires, or this message consumer is closed. A timeout of 0 never expires and the call blocks indefinitely.
Parameters:
consumerId - the consumer identifier
timeout - the timeout interval, in milliseconds
Returns:
the next message produced for the consumer, or null if the timeout expires or the consumer concurrently closed
Throws:
javax.jms.JMSException - if the next message can't be received

receiveNoWait

public MessageImpl receiveNoWait(long consumerId)
                          throws javax.jms.JMSException
Receive the next message if one is immediately available.
Parameters:
consumerId - the consumer identifier
Returns:
the next message produced for this consumer, or null if one is not available
Throws:
javax.jms.JMSException - if the next message can't be received

browse

public java.util.List browse(long consumerId,
                             int count)
                      throws javax.jms.JMSException
Browse up to count messages.
Parameters:
consumerId - the consumer identifier
count - the maximum number of messages to receive
Returns:
a list of MessageImpl instances
Throws:
javax.jms.JMSException - for any JMS error

sendMessage

protected void sendMessage(javax.jms.Message message)
                    throws javax.jms.JMSException
Send the specified message to the server.
Parameters:
message - the message to send
Throws:
javax.jms.JMSException - if the message can't be sent

getServerSession

protected ServerSession getServerSession()
Returns the server session.
Returns:
the server session

getConnection

protected org.exolab.jms.client.JmsConnection getConnection()
Return a reference to the connection that created this session.
Returns:
the owning connection

allocateConsumer

protected long allocateConsumer(javax.jms.Destination destination,
                                java.lang.String selector,
                                boolean noLocal)
                         throws javax.jms.JMSException
Creates a new message consumer, returning its identity.
Parameters:
destination - the destination to access
selector - the message selector. May be null
noLocal - if true, and the destination is a topic, inhibits the delivery of messages published by its own connection. The behavior for noLocal 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.

checkForValidTemporaryDestination

protected boolean checkForValidTemporaryDestination(JmsDestination destination)
This method checks the destination. If the destination is not temporary then return true. If it is a temporary destination and it is owned by this session's connection then it returns true. If it is a tmeporary destination and it is owned by another connection then it returns false
Parameters:
destination - the destination to check
Returns:
true if the destination is valid

addConsumer

protected void addConsumer(org.exolab.jms.client.JmsMessageConsumer consumer)
Add a consumer to the list of consumers managed by this session.
Parameters:
consumer - the consumer to add

removeConsumer

protected void removeConsumer(org.exolab.jms.client.JmsMessageConsumer consumer)
                       throws javax.jms.JMSException
Remove a consumer, deregistering it on the server.
Parameters:
consumer - the consumer to remove
Throws:
javax.jms.JMSException - if removal fails

addProducer

protected void addProducer(org.exolab.jms.client.JmsMessageProducer producer)
Add a producer to the list of producers managed by this session.
Parameters:
producer - the producer to add

removeProducer

protected void removeProducer(org.exolab.jms.client.JmsMessageProducer producer)
Remove the producer from the list of managed producers.
Parameters:
producer - the producer to remove

isClosed

protected final boolean isClosed()
Check if the session is closed.
Returns:
true if the session is closed

addMessage

protected void addMessage(javax.jms.Message message)
Add a message to the message cache. This message will be processed when the run() method is called.
Parameters:
message - the message to add.

ensureOpen

protected void ensureOpen()
                   throws javax.jms.IllegalStateException
Verifies that the session isn't closed.
Throws:
javax.jms.IllegalStateException - if the session is closed


Copyright © 1999-2007 The OpenJMS Group. All Rights Reserved.