Mock implementation of JMS Session.
Please note that this implementation does not
implement transaction isolation at the moment.
Messages are immediately sent. If acknowledge
mode is AUTO_ACKNOWLEDGE or DUPS_OK_ACKNOWLEDGE,
the message will be automatically acknowledged,
otherwise, it will not be acknowledged. According
to JMS specification, the acknowledged mode must
be ignored for transacted sessions. This is currently
not implemented, i.e. transacted sessions behave like
sessions with acknowledge mode AUTO_ACKNOWLEDGE.
Messages are acknowledged even if the transaction is
rolled back. However, the framework keeps track if a
transaction is committed or rolled back, so you can test
this and rely on the container for the rest.
You can set a MessageListener directly to
the session. This is an application server internal feature
and not meant for application use in JMS.
This mock session dispatches any message of any
known Queue and Topic to the
distinguished MessageListener, if such
a MessageListener is registered.
public Queue createQueue(String name) throws JMSException(Code)
createStreamMessage
public StreamMessage createStreamMessage() throws JMSException(Code)
createTemporaryQueue
public TemporaryQueue createTemporaryQueue() throws JMSException(Code)
createTemporaryTopic
public TemporaryTopic createTemporaryTopic() throws JMSException(Code)
createTextMessage
public TextMessage createTextMessage() throws JMSException(Code)
createTextMessage
public TextMessage createTextMessage(String text) throws JMSException(Code)
createTopic
public Topic createTopic(String name) throws JMSException(Code)
getAcknowledgeMode
public int getAcknowledgeMode() throws JMSException(Code)
Note: Returns 0 if the session is transacted.
This method does not exist in JMS 1.0.2. In JMS 1.1 it
should return Session.SESSION_TRANSACTED
which is specified as 0. In order to avoid
different versions for JMS 1.0.2 and 1.1
(Session.SESSION_TRANSACTED does not
exist in 1.0.2) this method returns hardcoded 0,
if the session is transacted.
the acknowledge mode
Returns a TemporaryQueue by its index. The
index represent the number of the queue. Returns null
if no such TemporaryQueue is present.
Parameters: index - the index the TemporaryQueue
Returns a TemporaryTopic by its index. The
index represent the number of the topic. Returns null
if no such TemporaryTopic is present.
Parameters: index - the index the TemporaryTopic
Returns if messages should be automatically acknowledged,
i.e. if the acknowledge mode is not CLIENT_ACKNOWLEDGE.
true if messages are automatically acknowledged