You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Thomas Beckmann <th...@freiheit.com> on 2009/03/06 15:36:03 UTC

Wrong destruction order when using spring dsl

Hi all,

we are using camel spring-dsl and we are routing from and to activemq.

We are using camel:bean and camel:process

I have the impression that in both cases the 'ref' property is not a real 
Spring reference (not wired by Spring) but is stored as a String and resolved 
later.

Because of that, Spring is not aware of the dependency and might destroy the 
references before destroying the camel context.

Additionally, there is no spring depency to the activemq component (it's just 
part of the uri), so it happens that the activemq connection pools get closed 
before the camel context.

Can anybody confirm my impression?

If so, is there a way to solve this problem?


Thanks
Thomas


Re: Wrong destruction order when using spring dsl

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Mar 6, 2009 at 3:36 PM, Thomas Beckmann
<th...@freiheit.com> wrote:
> Hi all,
>
> we are using camel spring-dsl and we are routing from and to activemq.
>
> We are using camel:bean and camel:process
>
> I have the impression that in both cases the 'ref' property is not a real
> Spring reference (not wired by Spring) but is stored as a String and resolved
> later.
Yes that is true, they are resolved by Camel as we have a neutral
registry API (see Registry in SPI) so it can resolve to any kind of
registry. Some users use JNDI or other kind of registry.

>
> Because of that, Spring is not aware of the dependency and might destroy the
> references before destroying the camel context.
You can add an id to the camel context, eg <camel id="myCamel" ...

And then refer to it from the regular spring beans using the
depends-on attribute.

>
> Additionally, there is no spring depency to the activemq component (it's just
> part of the uri), so it happens that the activemq connection pools get closed
> before the camel context.
Yeah when you use the camel and broker namespace to configure them.
You can also use regular spring bean style to setup Camel, eg. <bean
id="myCamel" ...>
There is a wiki page about it from the user guide - using Spring

Maybe using that you will be able to instruct Spring the correct order
of shutdown.

If you can get it to work nicely with regular spring bean style,
please post your findings,
so we can try to improve it in the future for the namespace as well so
we can have nice shutdown
with Camel and ActiveMQ.

I recently looked into it as well and it can be tricky. So if you have
time and want to investigate that would be awesome.



>
> Can anybody confirm my impression?
>
> If so, is there a way to solve this problem?
See above with the regular spring bean style

>
>
> Thanks
> Thomas
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/