Please call the end() after you call the delay() function, then you will get
same result as not using delay() function.
As you know delay is a delegate processor,  end() will tell him there is no
other processor it should be delegated to call. 

Willem


marbor wrote:
> 
> Hi all:
> 
> I have a DSL that works as expected, but when I add delay()'s, it doesn't. 
>  Is this a bug or do I not understand the delay() function?
> 
> Test Class:
> 
> public class ChoiceTesting extends CamelTestSupport {
> 
>     @Override
>     protected RouteBuilder createRouteBuilder() throws Exception {
>         return new RouteBuilder() {
>             @Override
>             public void configure() throws Exception {
>                 from("direct:start")
>                     .log("Starting testing")
>                     .multicast().stopOnException()
>                         .pipeline()
>                             .log("In the beginning!  Body=${body}")
>                             .to("direct:dummy")
>                             .choice()
>                                 .when(header("KEY").isNotEqualTo("VALUE"))
>                                     .log("choice 1")
>                                     .wireTap("direct:dummy")
>                                     //.delay(500)
>                                     .choice()
>  .when(header("KEY").isNotEqualTo("VALUE"))
>                                             .log("choice 2")
>                                             .to("direct:dummy")
>                                             //.delay(500)
>                                             .choice()
>  .when(header("KEY").isEqualTo("VALUE"))
>                                                     .log("choice 3")
>                                                     .throwException(new 
> RuntimeException("Some Error"))
>                                             .end()
>                                     .end()
>                             .end()
>                         .end()
>                         .to("direct:middle")
>                         .pipeline()
>                             .log("In the end!  Body=${body}")
>                         .end();
> 
>                 from("direct:middle")
>                     .log("In the middle!  Body=${body}");
> 
>                 from("direct:dummy")
>                     .setBody().constant("DUMMY");
>             }
>         };
>     }
> 
>     @Test
>     public void run() {
>         template.sendBody("direct:start", "X");
>     }
> }
> 
> Produces the expected output of:
> 
> 2011-01-24 15:16:42,891 INFO  route1 - Starting testing
> 2011-01-24 15:16:42,891 INFO  route1 - In the beginning!  Body=X
> 2011-01-24 15:16:42,891 INFO  route1 - choice 1
> 2011-01-24 15:16:42,891 INFO  route1 - choice 2
> 2011-01-24 15:16:42,891 INFO  route2 - In the middle!  Body=X
> 2011-01-24 15:16:42,891 INFO  route1 - In the end!  Body=X
> 
> But when I uncomment the delay() calls, the output changes to:
> 
> 2011-01-24 15:23:55,477 INFO  route1 - Starting testing
> 2011-01-24 15:23:55,477 INFO  route1 - In the beginning!  Body=X
> 2011-01-24 15:23:55,477 INFO  route1 - choice 1
> 2011-01-24 15:23:55,977 INFO  route1 - choice 2
> 2011-01-24 15:23:56,477 INFO  route2 - In the middle!  Body=DUMMY
> 2011-01-24 15:23:56,477 INFO  route1 - In the end!  Body=DUMMY
> 
> I'm using Camel 2.5.0.
> 
> Thanks in advance,
> Mark
> 
> Mark Borner
> Java Developer - ZStream Xpress
> 
> ----
> This email is intended for the named recipient only. It may contain 
> information which is confidential, commercially sensitive, or 
> copyright. If you are not the intended recipient you must not 
> reproduce or distribute any part of the email, disclose its contents, 
> or take any action in reliance. If you have received this email in 
> error, please contact the sender and delete the message. It is your 
> responsibility to scan this email and any attachments for viruses and 
> other defects. To the extent permitted by law, Zurich and its 
> associates will not be liable for any loss or damage arising in any 
> way from this communication including any file attachments. We may 
> monitor email you send to us, either as a reply to this email or any 
> email you send to us, to confirm our systems are protected and for 
> compliance with company policies. Although we take reasonable 
> precautions to protect the confidentiality of our email systems, we 
> do not warrant the confidentiality or security of email or 
> attachments we receive.
> 
-- 
View this message in context: 
http://camel.465427.n5.nabble.com/Delay-causes-unexpected-results-tp3354254p3357308.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to