You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by lunchbox <lu...@gmail.com> on 2011/07/12 15:08:23 UTC

RouteDefinition.setAutoStartup, PolicyDefinition ClassCastException

Hi all,

I have a route definition like so

RouteDefinition myRoute = (RouteDefinition)
from(...).routeId(MY_ROUTE)
  .transacted()
  ...;

myRoute.setAutoStartup("false");

I'd like to NOT have this route automatically start -- and there is
RouteDefinition.setAutoStartup for that. However, adding that transacted()
makes the chained method call actually an instance of PolicyDefinition. This
will cause a ClassCastException when I try to cast it to RouteDefinition.

What's the deal with this?

I'm defining the route in the RouteBuilder.configure method. Also, trying
getContext().getRouteDefinition(MY_ROUTE) at the end of the method will not
help since at this point it will always return null.

What can I do to have the route transactional and not auto-started?

Thanks,
Lunchbox


--
View this message in context: http://camel.465427.n5.nabble.com/RouteDefinition-setAutoStartup-PolicyDefinition-ClassCastException-tp4578805p4578805.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: RouteDefinition.setAutoStartup, PolicyDefinition ClassCastException

Posted by lunchbox <lu...@gmail.com>.
Awesome, thanks!

--
View this message in context: http://camel.465427.n5.nabble.com/RouteDefinition-setAutoStartup-PolicyDefinition-ClassCastException-tp4578805p4578974.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: RouteDefinition.setAutoStartup, PolicyDefinition ClassCastException

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jul 12, 2011 at 3:45 PM, lunchbox <lu...@gmail.com> wrote:
> Thanks Claus.
>
> Does it matter if I put noAutoStartup before onException() and transacted()?
> Both these return objects which are statically typed to something else than
> RouteDefinition.
>

Yep put it in the start, before the transacted() etc.

> Thanks again for the really quick answer.
>
> BR,
> Lunchbox
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/RouteDefinition-setAutoStartup-PolicyDefinition-ClassCastException-tp4578805p4578919.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: RouteDefinition.setAutoStartup, PolicyDefinition ClassCastException

Posted by lunchbox <lu...@gmail.com>.
Thanks Claus.

Does it matter if I put noAutoStartup before onException() and transacted()?
Both these return objects which are statically typed to something else than
RouteDefinition.

Thanks again for the really quick answer.

BR,
Lunchbox

--
View this message in context: http://camel.465427.n5.nabble.com/RouteDefinition-setAutoStartup-PolicyDefinition-ClassCastException-tp4578805p4578919.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: RouteDefinition.setAutoStartup, PolicyDefinition ClassCastException

Posted by Claus Ibsen <cl...@gmail.com>.
You can use

.noAutoStartup() on the RouteDefinition to indicate to not startup,
and its a fluent builder so you can use it in the DSL.

On Tue, Jul 12, 2011 at 3:08 PM, lunchbox <lu...@gmail.com> wrote:
> Hi all,
>
> I have a route definition like so
>
> RouteDefinition myRoute = (RouteDefinition)
> from(...).routeId(MY_ROUTE)
>  .transacted()
>  ...;
>
> myRoute.setAutoStartup("false");
>
> I'd like to NOT have this route automatically start -- and there is
> RouteDefinition.setAutoStartup for that. However, adding that transacted()
> makes the chained method call actually an instance of PolicyDefinition. This
> will cause a ClassCastException when I try to cast it to RouteDefinition.
>
> What's the deal with this?
>
> I'm defining the route in the RouteBuilder.configure method. Also, trying
> getContext().getRouteDefinition(MY_ROUTE) at the end of the method will not
> help since at this point it will always return null.
>
> What can I do to have the route transactional and not auto-started?
>
> Thanks,
> Lunchbox
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/RouteDefinition-setAutoStartup-PolicyDefinition-ClassCastException-tp4578805p4578805.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/