0

I have an Apache Camel route which purpose is to fetch xml-documents and files linked in the document.

<route id="route-ftp">
     <from uri="ftp://foo@server:21/data?password=xxx&amp;include=.*.xml"/>
     <to uri="myBean"/>
 </route>

When it reaches myBean I want to parse the file and use the same ftp settings to fetch the files listed in the xml-file. Or perhaps fetch them all at the same time using xpath.

<root>
    <article>
        <headline>Headline</headline>
        <image src="images/cat.jpg"/>
    </article>
</root>

The filenames is taken from the above xml image tag and src attribute.

I then want to deliver the original file together with my images in a package.

I can't find the right approach to my problem.

imfredde
  • 11
  • 4
  • Welcome to StackOverflow, please provide code to what you have tried and explain the problems you have faced in said code, so the users here can help you – Mário Fernandes Aug 21 '17 at 10:37

1 Answers1

2

I would probably do it this way.

  1. Depending on how your file is structured, I would consume it as you have done. I would then split the body per row (assuming each row contains a filename). The split is done using the splitter EIP. Now each body contains the file name.

  2. I would then use Camel's dynamicTo to enrich the route with the file using the ftp parameters. You can save the ftp parameters are properties so that they are always the same.

In this way, you fetch the list, iterate over the list and fetch the file for every row in the list.

Souciance Eqdam Rashti
  • 3,143
  • 3
  • 15
  • 31