You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicemix.apache.org by Martin Landua <ma...@union-investment.de> on 2007/06/22 15:54:37 UTC

Transaction Exception due to ServiceMix JMS Provider

Hi all,

under heavy load, we have encountered a problem when writing messages using
the JMS provider in a synchronous, transactional flow.

The problem is that in the code (lines 100 and up)

            producer.send(msg);
            exchange.setStatus(ExchangeStatus.DONE);
            channel.send(exchange);
        } finally {
            if (session != null) {
                session.close();
            }
            if (connection != null) {
                connection.close();
            }
        }

it is possible that the DONE state would return to the originator faster
than the session and the connection is closed in the finally section. If
this happens, the originator (and therefore owner of the transaction) will
first commit and after this the provider would close the connection.

This results in a transaction exception.

>From what we can tell, it should read like this:

            producer.send(msg);
        } finally {
            if (session != null) {
                session.close();
            }
            if (connection != null) {
                connection.close();
            }
        }

            exchange.setStatus(ExchangeStatus.DONE);
            channel.send(exchange);

due to which we guarantee that the connection is safely closed before we
send the confirmation back to the consumer.

All of our load tests succeeded after this change.

Best regards

Martin Landua
-- 
View this message in context: http://www.nabble.com/Transaction-Exception-due-to-ServiceMix-JMS-Provider-tf3964830s12049.html#a11252736
Sent from the ServiceMix - Dev mailing list archive at Nabble.com.


Re: Transaction Exception due to ServiceMix JMS Provider

Posted by Guillaume Nodet <gn...@gmail.com>.
Sorry I missed this mail.
Could you please raise a JIRA and attach your patch ?
Thanks a lot !

On 6/22/07, Martin Landua <ma...@union-investment.de> wrote:
>
>
> Hi all,
>
> under heavy load, we have encountered a problem when writing messages
> using
> the JMS provider in a synchronous, transactional flow.
>
> The problem is that in the code (lines 100 and up)
>
>             producer.send(msg);
>             exchange.setStatus(ExchangeStatus.DONE);
>             channel.send(exchange);
>         } finally {
>             if (session != null) {
>                 session.close();
>             }
>             if (connection != null) {
>                 connection.close();
>             }
>         }
>
> it is possible that the DONE state would return to the originator faster
> than the session and the connection is closed in the finally section. If
> this happens, the originator (and therefore owner of the transaction) will
> first commit and after this the provider would close the connection.
>
> This results in a transaction exception.
>
> From what we can tell, it should read like this:
>
>             producer.send(msg);
>         } finally {
>             if (session != null) {
>                 session.close();
>             }
>             if (connection != null) {
>                 connection.close();
>             }
>         }
>
>             exchange.setStatus(ExchangeStatus.DONE);
>             channel.send(exchange);
>
> due to which we guarantee that the connection is safely closed before we
> send the confirmation back to the consumer.
>
> All of our load tests succeeded after this change.
>
> Best regards
>
> Martin Landua
> --
> View this message in context:
> http://www.nabble.com/Transaction-Exception-due-to-ServiceMix-JMS-Provider-tf3964830s12049.html#a11252736
> Sent from the ServiceMix - Dev mailing list archive at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet
------------------------
Principal Engineer, IONA
Blog: http://gnodet.blogspot.com/