Re: Rép: Splitting Message from Ftp Consumer

2014-12-10 Thread Noam Ramonet
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  51283 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.txtlocalWorkDirectory=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.txtlocalWorkDirectory=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 ListString splitFtpFile(String remote){
return Arrays.asList(remote.split(\n));
}
}


Re: Rép: Splitting Message from Ftp Consumer

2014-12-10 Thread noamRamonet
Correction. Inserting an explicit conversion to String solves the problem: 
 
route id=fromFtp2SOAP
from uri=ftp://user:pass@host/
postalBox/inBox?fileName=simpleTextData.txtamp;localWorkDirectory=tempamp;binary=true/
convertBodyTo type=String/
split streaming=true
 tokenize token=\n/
 log loggingLevel=INFO message=Line: ${body}/
 to uri=direct:continue/
/split
/route




--
View this message in context: 
http://camel.465427.n5.nabble.com/Rep-Splitting-Message-from-Ftp-Consumer-tp5760220p5760489.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Rép: Splitting Message from Ftp Consumer

2014-12-05 Thread Francois Liot
Your issue is probably due to the fact you use \n as separator.

Use binary ftp option, to guaranty you will receive the very same encoded ascii 
stream as it could be hosted remote side, and test other fragrances of CRLF 
(\r\n, \n...).


Noam Ramonet noamramo...@gmail.com a écrit :

Hi all,

I’m getting an strange behaviour splitting a message body coming from a ftp
consumer. Below route works perfectly when I use a local file consumer
(line commented). I get a log message per file input line, and I can
process the content later correctly.



But when I change to the ftp I get the file information data:


[fromFtp2SOAP] INFO - Line: -rw-r--r--1 513  51283 Dec
05 09:55 simpleTextData.txt



The log line with “ftp:${body}” present correctly the full text content of
the file.



I have tried with and without localWorkDirectory option, with same result.



Any clue? Thanks in advance.
route id=fromFtp2SOAP
 from uri=ftp://user:pass@host
/postalBox/inBox?fileName=simpleTextData.txtamp;localWorkDirectory=temp/
 !-- from
uri=file:temp/inBox?noop=trueamp;fileName=simpleTextData.txt/ --
 log loggingLevel=INFO message=ftp: ${body}/
 split streaming=true
tokenize token=\n/
log loggingLevel=INFO message=Line: ${body}/
to uri=direct:continue/
 /split
   /route


Re: Rép: Splitting Message from Ftp Consumer

2014-12-05 Thread Noam Ramonet
Thanks Francois for your suggestions.

I forced binary and changed tokenize pattern to ; (semicolon), but
problem remains:

route id=fromFtp2SOAP
 from uri=ftp://user:pass@host/
postalBox/inBox?fileName=simpleTextData.txtamp;localWorkDirectory=tempamp;binary=true/
 !-- from
uri=file:temp/inBox?noop=trueamp;fileName=simpleTextData.txt/ --
 log loggingLevel=INFO message=ftp: ${body}/
 split streaming=true
tokenize token=;/
log loggingLevel=INFO message=Line: ${body}/
to uri=direct:continue/
 /split
   /route




2014-12-05 14:24 GMT+01:00 Francois Liot francois.l...@poplidays.com:

 Your issue is probably due to the fact you use \n as separator.

 Use binary ftp option, to guaranty you will receive the very same encoded
 ascii stream as it could be hosted remote side, and test other fragrances
 of CRLF (\r\n, \n...).


 Noam Ramonet noamramo...@gmail.com a écrit :

 Hi all,
 
 I’m getting an strange behaviour splitting a message body coming from a
 ftp
 consumer. Below route works perfectly when I use a local file consumer
 (line commented). I get a log message per file input line, and I can
 process the content later correctly.
 
 
 
 But when I change to the ftp I get the file information data:
 
 
 [fromFtp2SOAP] INFO - Line: -rw-r--r--1 513  51283 Dec
 05 09:55 simpleTextData.txt
 
 
 
 The log line with “ftp:${body}” present correctly the full text content of
 the file.
 
 
 
 I have tried with and without localWorkDirectory option, with same result.
 
 
 
 Any clue? Thanks in advance.
 route id=fromFtp2SOAP
  from uri=ftp://user:pass@host

 /postalBox/inBox?fileName=simpleTextData.txtamp;localWorkDirectory=temp/
  !-- from
 uri=file:temp/inBox?noop=trueamp;fileName=simpleTextData.txt/ --
  log loggingLevel=INFO message=ftp: ${body}/
  split streaming=true
 tokenize token=\n/
 log loggingLevel=INFO message=Line: ${body}/
 to uri=direct:continue/
  /split
/route



Re: Rép: Splitting Message from Ftp Consumer

2014-12-05 Thread François LIOT
Do a route that will simply grab the file and store it locally, check the 
difference between what you really get, and what you want to treat.

route

from uri=ftp://user:pass@host/
postalBox/inBox?fileName=simpleTextData.txtamp;localWorkDirectory=tempamp;binary=true/

setHeader 
headerName=CamelFilenameconstantinitial.txt/constant/setHeader
wireTap uril=file://temp/recieved


convertBodyTo type=java.lang.String/


setHeader 
headerName=CamelFilenameconstantafter_text_conversion.txt/constant/setHeader
wireTap uril=file://temp/recieved


split 



next, analyze initial.txt and after_text_conversion.txt with hexdump or 
equivalent,

And you will certainly see what to use as separator.


(you can also do the same exercise without binary option, but your code will be 
less portable, from an OS to an other...)




François Liot
Directeur de production et des systèmes d'information
Email : francois.l...@poplidays.commailto:francois.l...@poplidays.com
www.poplidays.comhttp://www.poplidays.com/

[1_logo]http://www.poplidays.com/?

From: Noam Ramonet noamramo...@gmail.com
Sent: Friday, December 5, 2014 3:15 PM
To: François LIOT
Cc: users@camel.apache.org
Subject: Re: Rép: Splitting Message from Ftp Consumer

Thanks Francois for your suggestions.

I forced binary and changed tokenize pattern to ; (semicolon), but problem 
remains:

route id=fromFtp2SOAP
 from uri=ftp://user:pass@host/
postalBox/inBox?fileName=simpleTextData.txtamp;localWorkDirectory=tempamp;binary=true/
 !-- from 
uri=file:temp/inBox?noop=trueamp;fileName=simpleTextData.txt/ --
 log loggingLevel=INFO message=ftp: ${body}/
 split streaming=true
tokenize token=;/
log loggingLevel=INFO message=Line: ${body}/
to uri=direct:continue/
 /split
   /route




2014-12-05 14:24 GMT+01:00 Francois Liot 
francois.l...@poplidays.commailto:francois.l...@poplidays.com:
Your issue is probably due to the fact you use \n as separator.

Use binary ftp option, to guaranty you will receive the very same encoded ascii 
stream as it could be hosted remote side, and test other fragrances of CRLF 
(\r\n, \n...).


Noam Ramonet noamramo...@gmail.commailto:noamramo...@gmail.com a écrit :

Hi all,

I'm getting an strange behaviour splitting a message body coming from a ftp
consumer. Below route works perfectly when I use a local file consumer
(line commented). I get a log message per file input line, and I can
process the content later correctly.



But when I change to the ftp I get the file information data:


[fromFtp2SOAP] INFO - Line: -rw-r--r--1 513  51283 Dec
05 09:55 simpleTextData.txt



The log line with ftp:${body} present correctly the full text content of
the file.



I have tried with and without localWorkDirectory option, with same result.



Any clue? Thanks in advance.
route id=fromFtp2SOAP
 from uri=ftp://user:pass@host
/postalBox/inBox?fileName=simpleTextData.txtamp;localWorkDirectory=temp/
 !-- from
uri=file:temp/inBox?noop=trueamp;fileName=simpleTextData.txt/ --
 log loggingLevel=INFO message=ftp: ${body}/
 split streaming=true
tokenize token=\n/
log loggingLevel=INFO message=Line: ${body}/
to uri=direct:continue/
 /split
   /route