On Wed, Nov 7, 2012 at 9:08 PM, Babak Vahdat <babak.vah...@swissonline.ch> wrote: > > > Am 07.11.12 09:28 schrieb "Babak Vahdat" unter > <babak.vah...@swissonline.ch>: > >>Hi >> >>There's a routing use case currently I'm stuck with which goes as the >>following: >> >>- Download an index file from a FTP server containing the list of (to be >>downloaded) files which're listed in this index file line by line >>- Do some futher processing with the index file being downloaded which is >>not relevant here >>- Download each file being listed inside the index file one after another. >>Any other potential file not being referenced inside the index file should >>be ignored >>- Do some further processing with each file being downloaded which is not >>relevant here >> >>The requirement is >> >>- Make use of Spring DSL >>- *If* possible do not write any single line of java code but make use of >>what Spring DSL can offer >> >>My first try was: >> >>from ftp://...fileName=index.txt >> to file://... >> ... >> convertBodyTo String >> split >> tokenize ... >> pollEnrich ftp://...fileName=...${in.body} >> ... >> split >> >>Now there're two problems here: >> >>According to what the read box says here: >> http://camel.apache.org/content-enricher.html >> >>I can not access anything from the current exchange to tell the pollEnrich >>the file name I want to download. >> >>And according: >> >>http://camel.465427.n5.nabble.com/pollEnrich-consumer-with-selector-td4939 >>908.html >> >>I can not make use of any other expression to tell the FTP polling >>consumer >>which file I intend to download. >> >>I appreciate any hint you could give me. > > At the end of the day I gave up using pollEnrich DSL and made use of > ConsumerTemplate wrapped inside a Bean which gets invoked through the Bean > endpoint inside Spring DSL. Just wonder if there's any better way to do > this. >
No this is fine. The PollEnrich is as it is currently due how the PollingConsumer API was crafted when Camel came to be. Camel 3.0 has API changes in the planning which can retrofit this issue and allow PollEnrich EIPs to be more dynamic > Ah, still completley another story which baffled me also a while: > DefaultPropertiesResolver.prepareLoadedProperties does *trim* a given > value. In my case I had a key/value pair defined inside a properties file > as: > > index-file-separator=\r\n > > Which of course after trimming became an empty string of the length 0! so > that the split step above using this value did not behave as expected. > IMHO it would be better to log at INFO or WARN level about this trimming > step so people are aware of this. To resolve this I overided the strategy > method as following: > No there is a lot of whitespace noise in files that causes problems for people. But we could maybe check if we can see if the text contains only \r \n \t chars and then ensure the trim won't trim out these. Feel free to log a JIRA for that. > public class MyPropertiesResolver extends DefaultPropertiesResolver { > @Override > protected Properties prepareLoadedProperties(Properties properties) { > // return the passed properties as is to avoid any value trimming taking > place by default > return properties; > } > } > > And then inside the test injected my own resolver: > > @Override > protected CamelContext createCamelContext() throws Exception { > CamelContext camelContext = super.createCamelContext(); > PropertiesComponent propertiesComponent = > camelContext.getComponent("properties", PropertiesComponent.class); > propertiesComponent.setPropertiesResolver(new MyPropertiesResolver()); > > return camelContext; > } > > > > Hope this can be helpful for others experiencing the same problem. > > Babak > >> >>Babak >> >> >> >> >>-- >>View this message in context: >>http://camel.465427.n5.nabble.com/Problem-with-pollEnrich-tp5722285.html >>Sent from the Camel - Users mailing list archive at Nabble.com. > > -- Claus Ibsen ----------------- Red Hat, Inc. FuseSource is now part of Red Hat Email: cib...@redhat.com Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen