camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Zhang <jmszh...@gmail.com>
Subject Re: Problem with ETL example
Date Wed, 08 Aug 2007 15:27:59 GMT



James.Strachan wrote:
> 
> On 8/8/07, James Zhang <jmszhang@gmail.com> wrote:
>>
>>
>>
>> James.Strachan wrote:
>> >
>> > On 8/8/07, jameszhang <jameszhang.james@gmail.com> wrote:
>> >> I have run the following testcase,and the result is failed too.
>> >>
>> >> //------------------ START SNIPPET
>> >> package org.apache.camel.component.file;
>> >>
>> >> import java.io.File;
>> >>
>> >> import org.apache.camel.ContextTestSupport;
>> >> import org.apache.camel.Exchange;
>> >>
>> >> public class FileExchangeTest extends ContextTestSupport {
>> >>
>> >>          public void testCopy() {
>> >>
>> >>                  File file = new
>> >>
>> File(FileExchangeTest.class.getResource("FileExchangeTest.class").getFile());
>> >>                  FileExchange fileExchange = new
>> >> FileExchange(context,file);
>> >>                  Exchange exchange = fileExchange.copy();
>> >>                  assertTrue("the copy of a FileExchange is not a
>> >> FileExchange instance",
>> >>
>> >> exchange instanceof FileExchange);
>> >>          }
>> >>
>> >> }
>> >> //------------------ END SNIPPET
>> >>
>> >> Thanks very much.
>> >
>> > Great catch James!
>> >
>> > I've added this test case to camel-core along with a patch to fix it -
>> > many thanks.
>> > --
>> > James
>> > -------
>> > http://macstrac.blogspot.com/
>> >
>> >
>>
>>
>> OK.
>> I think I can write the spring example now.
> 
> Great! :)
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> 


hi:
I should modify the "org.apache.camel.processor.Pipeline" to make the
example finally works.

    protected Exchange createNextExchange(Processor producer, Exchange
previousExchange) {
        Exchange answer = copyExchangeStrategy(previousExchange);

        //-----JamesZhang ADD BEGIN
        Object input = previousExchange.getIn().getBody();
        if (input != null) {
            answer.getIn().setBody(input);
        }
        //-----JamesZhang ADD END
        
        // now lets set the input of the next exchange to the output of the
        // previous message if it is not null
        Object output = previousExchange.getOut().getBody();
        if (output != null) {
            answer.getIn().setBody(output);
        }
        return answer;
    } 

If I do not do that,the body of copy FileExchange is null;and the router
finally find to use org.apache.camel.converter.jaxb.FallbackTypeConverter.
But we should expect to use
org.apache.camel.example.etl.CustomerTransformer.

The example works now.
There should be a better scheme to fix it.Thanks.:confused:
-- 
View this message in context: http://www.nabble.com/Problem-with-ETL-example-tf4235529s22882.html#a12055635
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message