You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by a746076drdrb <a7...@drdrb.net> on 2014/05/08 10:49:52 UTC

wiretap in otherwise does not work

Hello,

I'm getting Exception: 

in thread "main" org.apache.camel.RuntimeCamelException:
java.lang.ClassCastException: org.apache.camel.model.OtherwiseDefinition
cannot be cast to org.apache.camel.model.ChoiceDefinition

when using wireTap in otherwise(). I've tried to use end() and endChoice()
but it doesn't help. Is it possible to use wiretap definition in otherwise
clause?



    from("timer://foo?fixedRate=true&period=3s")
        .choice()
            .when(property("falseproperty").isEqualTo(true))
                .to("direct:falseproperty")
            .otherwise()
                .wireTap("direct:wiretapp")
                    .newExchangeBody(constant("in wiretap"))
                    .end()
                .setBody(constant("after wiretapping"))
                .to("log:end")
        .endChoice();





--
View this message in context: http://camel.465427.n5.nabble.com/wiretap-in-otherwise-does-not-work-tp5750955.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: wiretap in otherwise does not work

Posted by Hilderich <hi...@yahoo.de>.
Hello All,

In my camel route there is also a wireTab inside the otherwise section of
choice and I got the same exception as mentioned above. Is there a solution
available for that issue?

Kind Regards
Hilderich



--
View this message in context: http://camel.465427.n5.nabble.com/wiretap-in-otherwise-does-not-work-tp5750955p5752407.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: wiretap in otherwise does not work

Posted by Hilderich <hi...@yahoo.de>.
Hello Claus,

Thank you for your help. I have incorporated ".endChoice()" together with
".newExchangeBody(...)" and now it is working. In my case
".newExchangeBody(...)" was the crucial thing.

Kind Regards
Hilderich.



--
View this message in context: http://camel.465427.n5.nabble.com/wiretap-in-otherwise-does-not-work-tp5750955p5752412.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: wiretap in otherwise does not work

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Do like this

                from("direct:start")
                        .choice()
                        .when(property("falseproperty").isEqualTo(true))
                        .to("direct:falseproperty")
                        .otherwise()
                            .wireTap("direct:wiretapp")
                                .newExchangeBody(constant("in wiretap"))
                            .endChoice()
                            .setBody(constant("after wiretapping"))
                            .to("log:end")
                        .end();

On Thu, May 8, 2014 at 10:49 AM, a746076drdrb <a7...@drdrb.net> wrote:
> Hello,
>
> I'm getting Exception:
>
> in thread "main" org.apache.camel.RuntimeCamelException:
> java.lang.ClassCastException: org.apache.camel.model.OtherwiseDefinition
> cannot be cast to org.apache.camel.model.ChoiceDefinition
>
> when using wireTap in otherwise(). I've tried to use end() and endChoice()
> but it doesn't help. Is it possible to use wiretap definition in otherwise
> clause?
>
>
>
>     from("timer://foo?fixedRate=true&period=3s")
>         .choice()
>             .when(property("falseproperty").isEqualTo(true))
>                 .to("direct:falseproperty")
>             .otherwise()
>                 .wireTap("direct:wiretapp")
>                     .newExchangeBody(constant("in wiretap"))
>                     .end()
>                 .setBody(constant("after wiretapping"))
>                 .to("log:end")
>         .endChoice();
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/wiretap-in-otherwise-does-not-work-tp5750955.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/