activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rob Davies (JIRA)" <>
Subject [jira] Resolved: (AMQ-2812) ActiveMqSession should throw JMSException instead of IllegalStateException if connection is closed
Date Thu, 08 Jul 2010 05:00:53 GMT


Rob Davies resolved AMQ-2812.

    Fix Version/s: 5.4.0
       Resolution: Won't Fix

The ActiveMQSession actually throws a javax.jms.IllegalStateException if the session is closed
when a commit() is called - which is correct. As javax.jms.IllegalStateException is derived
from javax.jms.JMSException  -I'm not sure how changing it to a vanilla JMSException will
fix your problem 

> ActiveMqSession should throw JMSException instead of IllegalStateException if connection
is closed
> --------------------------------------------------------------------------------------------------
>                 Key: AMQ-2812
>                 URL:
>             Project: ActiveMQ
>          Issue Type: Bug
>    Affects Versions: 5.3.2
>         Environment: Spring 2.5.6
>            Reporter: Morten Andersen-Gott
>            Assignee: Rob Davies
>            Priority: Critical
>             Fix For: 5.4.0
> ActiveMqSession throws IllegalStateException if connection is closed. The ActiveMqSession.checkClosed()
will throw the exception if the connection is lost. This is really an internal error which
according to the javax.jms.Session.commit javadoc should result in a JMSException.
> The distinction between the two exceptions becomes important when using Spring and ActiveMq.
When doing JMS inside a codeblock that is managed by a HibernateTransactionManager (or any
other non-JmsTransactionManager/non-JtaTransactionManager) TransactionSynchronizationUtils
will try to commit the jms session after the HibernateTransactionManager has committed. This
is done by calling the JmsResourceHolder.commitAll() from TransactionSynchronizationManager.invokeAfterCommit().
JmsResourceHolder.commitAll() will silently ignore IllegalStateExceptions as these are only
supposed to happen in the case of a JTA transaction.
> If ActiveMqSession.commit -> ActiveMqSession.checkClosed() were to throw a JMSException
it would propagate out of the TransactionSynchronizationUtils and at least the application
would be made aware that the JMSSession was not committed.
> Below is the description of IllegalStateException from the JMS Specification:
> IllegalStateException: This exception is thrown when a method is invoked a
> an illegal or inappropriate time or if the provider is not in an appropriate 
> state for the requested operation. For example, this exception must be 
> thrown if Session.commit() is called on a non-transacted session. This 
> exception is also must be called when domain inappropriate method is 
> called, such as calling TopicSession.CreateQueueBrowser().
> While it does not specifically state that a closed connection should _NOT_ throw an IllegalStateException,
it would seem that throwing a JMSException is a better choice. Especially when IllegalStateException
causes problems when using Spring.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message