This is getting confusing :(

The docs for SEDA seem to say this should always be async.
Link: http://camel.apache.org/seda.html

They provide the following sample

[code]
public void configure() throws Exception {
    from("direct:start")
        // send it to the seda queue that is async     <<<<<
        .to("seda:next")
        // return a constant response
        .transform(constant("OK"));
 
    from("seda:next").to("mock:result");
}

Object out = template.requestBody("direct:start", "Hello World");
assertEquals("OK", out);
[/code]

However when I add some logs to it I get a pretty synchronous result.

[code]
import org.apache.camel.ExchangePattern;
import org.apache.camel.Produce;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;

public class AsynchTest extends CamelTestSupport { 
        protected RouteBuilder createRouteBuilder() throws Exception { 
                return new RouteBuilder() { 
              
                        @Override 
                        public void configure() { 
                                                                
                                from("direct:start")
                                        .log("AAA: The Body Before SEDA Call is 
${in.body}")    // Hello World
                                // send it to the seda queue that is async
                                .to("seda:next")
                                // return a constant response
                                .log("AAA: Return from BBB!")
                                .transform(constant("OK"));
                         
                            from("seda:next")
                                .log("BBB: Going to wait for five seconds!")
                                .delay(5000)
                                .to("mock:result")
                                .log("BBB: I am ready!");
                                
                        } 
                }; 
        } 
          
        @Test 
        public void requestReply() { 

                Object out = super.template.requestBody("direct:start", "Hello 
World");
                assertEquals("OK", out);
        }
} 
[/code]

[output]
[                          main] route1                         INFO  AAA:
The Body Before SEDA Call is Hello World
[mel-1) thread #0 - seda://next] route2                         INFO  BBB:
Going to wait for five seconds!
[mel-1) thread #0 - seda://next] route2                         INFO  BBB: I
am ready!
[                          main] route1                         INFO  AAA:
Return from BBB!
[/output]

If I set the ExchangePattern to InOnly then it works async.

[output]
[                          main] route1                         INFO  AAA:
The Body Before SEDA Call is Hello World
[                          main] route1                         INFO  AAA:
Return from BBB!
...
[mel-1) thread #0 - seda://next] route2                         INFO  BBB:
Going to wait for five seconds!
...
[mel-1) thread #0 - seda://next] route2                         INFO  BBB: I
am ready!
[/output]



sim085 wrote
> I have changed the code a little and ran the test again. From what I can
> see the SEDA endpoint acts correctly to the InOut and InOnly
> ExchangePattern, i.e. - acts asynchronously when called with InOnly and
> synchronously when called with InOut.





--
View this message in context: 
http://camel.465427.n5.nabble.com/Can-t-understand-what-inOnly-is-doing-tp5787961p5788123.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to