Hello, I have a route that queries a database table for a list of urls.
The results are then split and passed to another route to actually perform
the lookup.

This works fine until, for performance reasons, I would like to process the
url lookups in parallel so I change the split to:
.split(body(java.util.ArrayList.class)).parallelProcessing().to("direct:split-url-lookup");

My sample data has three rows of URLs so without parallelProcessing each
url is looked up in sequence. With parallelProcessing
the last row returned by the SQL resultSet is looked up 3 times.

I'm guessing this is me not understanding how the split EIP works properly
but can someone point out what's happening here?

Camel version is 2.10.7
thanks, John.

from("timer:bar?period=1s&repeatCount=1")
.to("sql:"+sql+"?dataSourceRef=dataSource")
.split(body(java.util.ArrayList.class)).to("direct:split-url-lookup");
 from("direct:split-url-lookup")
.process(new UrlResultRowProcessor())
.to("http4:dummy")
.choice()
.when(simple("${in.header.CamelHttpResponseCode} == 200"))
.to("direct:split-url-lookup-success")
.otherwise()
.log("Failed")
.endChoice();


public class UrlResultRowProcessor implements Processor {

@Override
public void process(Exchange exchange) throws Exception {
 Map<String, Object> outHeaders = null;
 Map<String, Object> row = (Map<String, Object>) exchange.getIn().getBody();
String url = row.get("url").toString();
System.out.println("***URL="+url);
outHeaders = exchange.getIn().getHeaders()
outHeaders.put(Exchange.HTTP_URI, url);
outHeaders.put("User-Agent",
"Mozilla/5.0 (X11; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0");
}
 exchange.getOut().setHeaders(outHeaders);
 }

}

Reply via email to