Hi,

I’ve testing a little more and the issue seems related to the Expresion
used by split to iterate.

Ftp consumers generates a message with body input of type  RemoteFile<
FtpFile>. org.apache.commons.net.ftp.FtpFile#toString() method returns the
strange splitted content which originated the post “-rw-r--r--    1
513      512            83 Dec 05 09:55 simpleTextData.txt”.

RouteBuilder#body() Expresion generates this String as output. It can be
seen using  Java DSL. Next route presents the same log as the Spring
counterpart:

from("ftp://user:pass@host
/postalBox/inBox?fileName=simpleTextData.txt&localWorkDirectory=temp")
.split(body().tokenize("\n"))
.log("Line: ${body}")
.end();

Whereas below route works as I need:

from("ftp://user:pass@host
/postalBox/inBox?fileName=simpleTextData.txt&localWorkDirectory=temp")
.split(body(String.class).tokenize("\n"))
.log("Line: ${body}")
.end();

Is there any way to force the String type conversion in Spring DSL? I
already tried <convertBodyTo type="java.lang.String"/>, pointed by
Francois, without success.

Is this an expected behaviour or a bug?

Meanwhile, a simple workaround for Spring DSL would be replacing the
tokenizer with a custom bean for splitting:

<split>
    <method bean="custoTokenizer" method="splitFtpFile"/>
    <log loggingLevel="INFO" message="Line: ${body}"/>
</split>

public class CustomTokenizer {
    public List<String> splitFtpFile(String remote){
        return Arrays.asList(remote.split("\n"));
    }
}

Reply via email to