You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "sb.append" <a2...@drdrb.net> on 2014/03/24 14:21:09 UTC
download files for each xml entry
Hello,
I've simple task to parse xml entries containing links to files. For each
entry the file should be downloaded. Is the following route a correct
approach?
from("direct:start")
.to("http://address.of.xml")
.filter()
.xpath("entry/link")
.to(body())
.to("file:input);
I'd like to add parallel download later too.
--
View this message in context: http://camel.465427.n5.nabble.com/download-files-for-each-xml-entry-tp5749276.html
Sent from the Camel - Users mailing list archive at Nabble.com.
RE: download files for each xml entry
Posted by Ra...@cognizant.com.
Here is what you can do .
from("direct:start")
.to("http://localhost/Files.xml")
.split(xpath("//file/text()")).parallelProcessing()
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
String fileName = exchange.getIn().getBody(String.class);
// Invoke copy functionality based on the protocol [ local or remote ]
}
});
Where Files.xml looks like this..
<files>
<file>D:\test1.xml</file>
<file>D:\test3.xml</file>
<file>D:\test4.xml</file>
</files>
- Ravi
-----Original Message-----
From: sb.append [mailto:a261427@drdrb.net]
Sent: Monday, March 24, 2014 6:51 PM
To: users@camel.apache.org
Subject: download files for each xml entry
Hello,
I've simple task to parse xml entries containing links to files. For each entry the file should be downloaded. Is the following route a correct approach?
from("direct:start")
.to("http://address.of.xml")
.filter()
.xpath("entry/link")
.to(body())
.to("file:input);
I'd like to add parallel download later too.
--
View this message in context: http://camel.465427.n5.nabble.com/download-files-for-each-xml-entry-tp5749276.html
Sent from the Camel - Users mailing list archive at Nabble.com.
This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful.
Re: download files for each xml entry
Posted by Richard Kettelerij <ri...@gmail.com>.
Hi,
I don't think using a filter yields the desired outcome. With this filter
you're only verifying whether the XML file contains a "entry/filter" node.
If the XML file is valid this will always succeed but it will not help you
in downloading additional files.
I guess what you're looking for is the *splitter*. With the splitter you
can process each "entry/link" node separately. Read about it:
http://camel.apache.org/splitter.html. Also the splitter allows for easily
adding parallel processing latter on:
split(xpath("entry/link")).parallelProcessing()......
Regards,
Richard
http://richardlog.com
On Mon, Mar 24, 2014 at 2:21 PM, sb.append <a2...@drdrb.net> wrote:
> Hello,
>
> I've simple task to parse xml entries containing links to files. For each
> entry the file should be downloaded. Is the following route a correct
> approach?
>
> from("direct:start")
> .to("http://address.of.xml")
> .filter()
> .xpath("entry/link")
> .to(body())
> .to("file:input);
>
> I'd like to add parallel download later too.
>
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/download-files-for-each-xml-entry-tp5749276.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>