Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 29125 invoked from network); 13 Jan 2010 11:52:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 13 Jan 2010 11:52:42 -0000 Received: (qmail 1927 invoked by uid 500); 13 Jan 2010 11:52:41 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 1873 invoked by uid 500); 13 Jan 2010 11:52:41 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 1863 invoked by uid 99); 13 Jan 2010 11:52:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jan 2010 11:52:41 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=MISSING_MID,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [211.99.232.114] (HELO tongtech.com) (211.99.232.114) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 13 Jan 2010 11:52:33 +0000 Received: from IBM0618 (unknown [124.42.76.2]) by tongtech.com with CMailServer 5.3 SMTP; Wed, 13 Jan 2010 19:52:01 +0800 From: "ext2" To: Subject: How to Understand InOnly and InOut pattern Date: Wed, 13 Jan 2010 19:52:10 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 In-Reply-To: <5380c69c1001130054n3d1f2784w22e9711b6d808bee@mail.gmail.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Thread-Index: AcqULh2hJkavaB60Tx6HyPYPrOfsbQAE5/iA Message-Id: <20100113115241.722F647841C@athena.apache.org> While learning camel's pattern, it seems the in only patter is very hard to understand; Following is a test-case from the camel's unit test( with a little change). inProcess bean just increase the input message body(as Integer) and set back to input message. outProcess bean just increase the input message and set result to output; 1) following route if using in-out pattern is easy to understand, if I send a input message number=1, and returned message-exchange's input is 1, output is 3; from("direct:a").process(outProcessor).process(outProcessor).to("mock:resul" ); but using in-only pattern, result message-exchange's input is 3, output is 2. the input is 3, we can understand as if processor doesn't return output, the input will act as next processor's input, so input is equal 3. but how to under-stand the output is 2? I think it should be null; 2) following route if using inonly pattern is easy to understand, if I send a input message whose body is 1, the result is : in-message is 3, out-message is null; from("direct:a").process(inProcessor).process(inProcessor).to("mock:resul"); but if I using in-out pattern, it's hard to understand. The result is in-message is 2, output-message is 3; how to understand the input-message is 2, I think it should be 1; Finally what is the real-rule for camel's MEP? Does it means if I use in-only MEP, the processor should only affect in-message, output message affect will be unpredictable, and so one for in-out MEP? final Processor inProcessor = new Processor() { public void process(Exchange exchange) { Integer number = exchange.getIn().getBody(Integer.class); number = number + 1; exchange.getIn().setBody(number); } }; final Processor outProcessor = new Processor() { public void process(Exchange exchange) { Integer number = exchange.getIn().getBody(Integer.class); number = number + 1; exchange.getOut().setBody(number); } };