You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by rwijngaa <ri...@gmail.com> on 2015/11/21 14:19:08 UTC

ftp multiple streams in body?

Hi, i've developed a simplified camellish DSL for my end-users in which they
can basically specify 
how they want files to be moved around. For the most part this works great,
but i don't have
a solution yet for the case where i read just one file and the end result is
N files.

For example this scenario:

<from uri="path-to-zip-file" />
<processor bean="unzipAndMoreMagic" />
<to uri="ftp-site" />

This is broken down to 3 parts:
1) read a zip file
2) unzip it to local file system 
3) send every file (can be more than one) from local filesystem to ftp
endpoint

1) and 2) are solved. But 3) is the problem here. How do i put the unzipped
file(s) on it's way to
the ftp end point?. One file is no problem, i just can do setBody(File) ...
But, can i just set multiple body's (streams) on the exchange
setBody(List<InputStream) and it will magicall work? 

Thanks in advance!
Regards
Rino








--
View this message in context: http://camel.465427.n5.nabble.com/ftp-multiple-streams-in-body-tp5774197.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: ftp multiple streams in body => custom splitter

Posted by rwijngaa <ri...@gmail.com>.
ok, so i thought it worked for all cases, but now i see it only copies the
last file in the zip!
In the debug log i see that the processor and aggregator are called N times
(for N number of files in the zip file)
..  Processing file /var/folders/mg/3ms51p890wgc9nl5y47d2s800000gn/T/file1
... Processing file /var/folders/mg/3ms51p890wgc9nl5y47d2s800000gn/T/file2
But only 1 file appears in the destination uri (file2 / always the last one
processed !)

So, almost there, but still need some help!!





--
View this message in context: http://camel.465427.n5.nabble.com/ftp-multiple-streams-in-body-custom-splitter-tp5774343p5774477.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: ftp multiple streams in body => custom splitter

Posted by Claus Ibsen <cl...@gmail.com>.
Maybe tell us a bit more about about your finding / solution. There
could be users in the future that find this thread and may have
similar issue and are looking for help.

On Thu, Nov 26, 2015 at 3:19 PM, rwijngaa
<ri...@gmail.com> wrote:
> never mind, i got it
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/ftp-multiple-streams-in-body-custom-splitter-tp5774343p5774445.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: ftp multiple streams in body => custom splitter

Posted by rwijngaa <ri...@gmail.com>.
never mind, i got it



--
View this message in context: http://camel.465427.n5.nabble.com/ftp-multiple-streams-in-body-custom-splitter-tp5774343p5774445.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: ftp multiple streams in body?

Posted by rwijngaa <ri...@gmail.com>.
Hi Claus,

i implemented a splitter (see below) but i'm not sure if this is the way to
go; i think this can be implemented more elegantly/simpler (but i don't know
how ;-). 
A unzipped file *does* come out, but where do i set the current filename (if
there are more than one) ?





--
View this message in context: http://camel.465427.n5.nabble.com/ftp-multiple-streams-in-body-tp5774197p5774343.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: ftp multiple streams in body?

Posted by rwijngaa <ri...@gmail.com>.
ah, ofcourse the good 'ol' splitter. Thanks Claus!



--
View this message in context: http://camel.465427.n5.nabble.com/ftp-multiple-streams-in-body-tp5774197p5774236.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: ftp multiple streams in body?

Posted by Claus Ibsen <cl...@gmail.com>.
You may want to use the splitter eip so after step 2, you split the
message body into N files and each file is uploaded. So if you have a
List<InputStream> at step 2, then the splitter can split the list out
of the box, and each InputStream is used for uploading to FTP.

However if you want to control the file name also, then you need to
set the CamelFileName header for each splitted message to the name you
want

from
 to
 split(body())
  setHeader(CamelFileName, someStuffHere)
  to ftp

See about splitter here
http://camel.apache.org/splitter


On Sat, Nov 21, 2015 at 2:19 PM, rwijngaa
<ri...@gmail.com> wrote:
> Hi, i've developed a simplified camellish DSL for my end-users in which they
> can basically specify
> how they want files to be moved around. For the most part this works great,
> but i don't have
> a solution yet for the case where i read just one file and the end result is
> N files.
>
> For example this scenario:
>
> <from uri="path-to-zip-file" />
> <processor bean="unzipAndMoreMagic" />
> <to uri="ftp-site" />
>
> This is broken down to 3 parts:
> 1) read a zip file
> 2) unzip it to local file system
> 3) send every file (can be more than one) from local filesystem to ftp
> endpoint
>
> 1) and 2) are solved. But 3) is the problem here. How do i put the unzipped
> file(s) on it's way to
> the ftp end point?. One file is no problem, i just can do setBody(File) ...
> But, can i just set multiple body's (streams) on the exchange
> setBody(List<InputStream) and it will magicall work?
>
> Thanks in advance!
> Regards
> Rino
>
>
>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/ftp-multiple-streams-in-body-tp5774197.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2