TransactionErrorHandler fails if Apache Camel context is shutting down?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

TransactionErrorHandler fails if Apache Camel context is shutting down?

Grant Sheppard
Hi everyone,

I've been testing a route that receives messages from a JMS topic, transforms them and then performs a POST to a REST service. One of my tests involved shutting down the REST service to ensure that the redelivery functionality was working (as well as rollback onto the JMS topic). This functionality works fine whilst Apache Camel remains up and I can see the rollbacks and redeliveries happening every minute, as per my configuration.

However when I shutdown JBoss (which my Camel context is deployed within) I hit a snag. The TransactionErrorHandler is invoked (as expected) whilst the context is shutting down but the results are not pretty. What *seems* to be happening is that it is attempting to create an instance of my redelivery policy (which is defined as a Spring bean) but failing to do so because it seems that the Spring context has also been told to commence shutdown (and is refusing to create or retrieve anymore singleton beans). Consequently this fails and then worst of all, the transaction commits and the original message is taken off the JMS topic.

I've attached the relevant portion of the log file showing this behaviour. Any advice would be appreciated!

Regards,

Grant Sheppard

transaction_rollback_failure.txt
Reply | Threaded
Open this post in threaded view
|

Re: TransactionErrorHandler fails if Apache Camel context is shutting down?

Grant Sheppard
Further to what I previously wrote, to me at least the root cause seems to be that the Spring context is shutdown immediately regardless of whether you've specified a shutdown timeout for the Camel context.

Does anyone know whether it's possible to only shutdown the Spring context after the Camel context is closed??
Reply | Threaded
Open this post in threaded view
|

Re: TransactionErrorHandler fails if Apache Camel context is shutting down?

Claus Ibsen-2
On Fri, Nov 30, 2012 at 1:04 AM, Grant Sheppard
<[hidden email]> wrote:
> Further to what I previously wrote, to me at least the root cause seems to be
> that the Spring context is shutdown immediately regardless of whether you've
> specified a shutdown timeout for the Camel context.
>
> Does anyone know whether it's possible to only shutdown the Spring context
> after the Camel context is closed??
>

Its not so easy with Spring to setup shutdown ordering. Though what
you can is to use "depends-on" on the <bean> attributes,
and possible somehow tell spring that your beans is dependet on <camelContext>.

You need to set the id attribute in <camelContext> so your <bean> can
depend-on that id.



>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/TransactionErrorHandler-fails-if-Apache-Camel-context-is-shutting-down-tp5723423p5723424.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Reply | Threaded
Open this post in threaded view
|

Re: TransactionErrorHandler fails if Apache Camel context is shutting down?

Grant Sheppard
Thanks, Claus. I've done this - the difficult part now is simulating the same conditions that occurred the first time around to test it.