You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Babak Vahdat <ba...@swissonline.ch> on 2012/11/07 09:28:28 UTC

Problem with pollEnrich

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-td4939908.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.

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.

Re: Problem with pollEnrich

Posted by Babak Vahdat <ba...@swissonline.ch>.

Am 09.11.12 16:45 schrieb "Claus Ibsen" unter <cl...@gmail.com>:

>On Thu, Nov 8, 2012 at 7:12 AM, Claus Ibsen <cl...@gmail.com> wrote:
>> On Wed, Nov 7, 2012 at 9:08 PM, Babak Vahdat
>> <ba...@swissonline.ch> wrote:
>>>
>>>
>>> Am 07.11.12 09:28 schrieb "Babak Vahdat" unter
>>> <ba...@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-td4
>>>>939
>>>>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.
>>
>
>I logged a ticket to not forget about this
>https://issues.apache.org/jira/browse/CAMEL-5784

Hi Claus,

I'm so sorry not to raise the JIRA by myself, please excuse me. I've been
really really too much busy these days with a couple of dev tasks at the
same time. As always thanks for your help and genius advices.

Babak

>
>>
>>> 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.htm
>>>>l
>>>>Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> Red Hat, Inc.
>> FuseSource is now part of Red Hat
>> Email: cibsen@redhat.com
>> Web: http://fusesource.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen
>
>
>
>-- 
>Claus Ibsen
>-----------------
>Red Hat, Inc.
>FuseSource is now part of Red Hat
>Email: cibsen@redhat.com
>Web: http://fusesource.com
>Twitter: davsclaus
>Blog: http://davsclaus.com
>Author of Camel in Action: http://www.manning.com/ibsen



Re: Problem with pollEnrich

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Nov 8, 2012 at 7:12 AM, Claus Ibsen <cl...@gmail.com> wrote:
> On Wed, Nov 7, 2012 at 9:08 PM, Babak Vahdat
> <ba...@swissonline.ch> wrote:
>>
>>
>> Am 07.11.12 09:28 schrieb "Babak Vahdat" unter
>> <ba...@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.
>

I logged a ticket to not forget about this
https://issues.apache.org/jira/browse/CAMEL-5784

>
>> 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: cibsen@redhat.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

RE: Exception occurs when deploy a Route Bundle which contains Javascript Language into Karaf

Posted by liugang <cl...@gmail.com>.
OK, thanks. Let me try

-----Original Message-----
From: Claus Ibsen [mailto:claus.ibsen@gmail.com] 
Sent: Thursday, November 08, 2012 3:58 PM
To: users@camel.apache.org
Subject: Re: Exception occurs when deploy a Route Bundle which contains
Javascript Language into Karaf

On Thu, Nov 8, 2012 at 8:41 AM, liugang <cl...@gmail.com> wrote:
> Yes, I installed the camel-script feature
> The camel version is 2.10.2, and karaf is 2.2.9
>
> For Groovy and jruby seems ok (because they are using external engine,
> right?)
>
> But for js, I have this problem. I think I have all dependencies.
>

You need to install camel-script-javascript also.


> -----Original Message-----
> From: Claus Ibsen [mailto:claus.ibsen@gmail.com]
> Sent: Thursday, November 08, 2012 3:38 PM
> To: users@camel.apache.org
> Subject: Re: Exception occurs when deploy a Route Bundle which contains
> Javascript Language into Karaf
>
> Hi
>
> Have you installed the camel-script feature beforehand?
> And what version of Karaf and Camel are you using?
>
>
> On Thu, Nov 8, 2012 at 8:34 AM, liugang <cl...@gmail.com> wrote:
>> Hi All:
>>
>> When I deploy a bundle which includes Javascript Language into Karaf, I
> got
>> an Exception "No Script engine could be created for:js"
>> This may be caused by the classloader problem, it can't find the
>> com.sun.script.javascript.RhinoScriptEngineFactory and
>> com.sun.script.javascript.RhinoScriptEngine.
>>
>> So does anybody have any idea how I can resolve this problem?
>>
>>
>> Thanks very much.
>> GangLiu
>>
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Email: cibsen@redhat.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: Exception occurs when deploy a Route Bundle which contains Javascript Language into Karaf

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Nov 8, 2012 at 8:41 AM, liugang <cl...@gmail.com> wrote:
> Yes, I installed the camel-script feature
> The camel version is 2.10.2, and karaf is 2.2.9
>
> For Groovy and jruby seems ok (because they are using external engine,
> right?)
>
> But for js, I have this problem. I think I have all dependencies.
>

You need to install camel-script-javascript also.


> -----Original Message-----
> From: Claus Ibsen [mailto:claus.ibsen@gmail.com]
> Sent: Thursday, November 08, 2012 3:38 PM
> To: users@camel.apache.org
> Subject: Re: Exception occurs when deploy a Route Bundle which contains
> Javascript Language into Karaf
>
> Hi
>
> Have you installed the camel-script feature beforehand?
> And what version of Karaf and Camel are you using?
>
>
> On Thu, Nov 8, 2012 at 8:34 AM, liugang <cl...@gmail.com> wrote:
>> Hi All:
>>
>> When I deploy a bundle which includes Javascript Language into Karaf, I
> got
>> an Exception "No Script engine could be created for:js"
>> This may be caused by the classloader problem, it can't find the
>> com.sun.script.javascript.RhinoScriptEngineFactory and
>> com.sun.script.javascript.RhinoScriptEngine.
>>
>> So does anybody have any idea how I can resolve this problem?
>>
>>
>> Thanks very much.
>> GangLiu
>>
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Email: cibsen@redhat.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

RE: Exception occurs when deploy a Route Bundle which contains Javascript Language into Karaf

Posted by liugang <cl...@gmail.com>.
Yes, I installed the camel-script feature 
The camel version is 2.10.2, and karaf is 2.2.9

For Groovy and jruby seems ok (because they are using external engine,
right?)

But for js, I have this problem. I think I have all dependencies. 

-----Original Message-----
From: Claus Ibsen [mailto:claus.ibsen@gmail.com] 
Sent: Thursday, November 08, 2012 3:38 PM
To: users@camel.apache.org
Subject: Re: Exception occurs when deploy a Route Bundle which contains
Javascript Language into Karaf

Hi

Have you installed the camel-script feature beforehand?
And what version of Karaf and Camel are you using?


On Thu, Nov 8, 2012 at 8:34 AM, liugang <cl...@gmail.com> wrote:
> Hi All:
>
> When I deploy a bundle which includes Javascript Language into Karaf, I
got
> an Exception "No Script engine could be created for:js"
> This may be caused by the classloader problem, it can't find the
> com.sun.script.javascript.RhinoScriptEngineFactory and
> com.sun.script.javascript.RhinoScriptEngine.
>
> So does anybody have any idea how I can resolve this problem?
>
>
> Thanks very much.
> GangLiu
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: Exception occurs when deploy a Route Bundle which contains Javascript Language into Karaf

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Have you installed the camel-script feature beforehand?
And what version of Karaf and Camel are you using?


On Thu, Nov 8, 2012 at 8:34 AM, liugang <cl...@gmail.com> wrote:
> Hi All:
>
> When I deploy a bundle which includes Javascript Language into Karaf, I got
> an Exception "No Script engine could be created for:js"
> This may be caused by the classloader problem, it can't find the
> com.sun.script.javascript.RhinoScriptEngineFactory and
> com.sun.script.javascript.RhinoScriptEngine.
>
> So does anybody have any idea how I can resolve this problem?
>
>
> Thanks very much.
> GangLiu
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Exception occurs when deploy a Route Bundle which contains Javascript Language into Karaf

Posted by liugang <cl...@gmail.com>.
Hi All:

When I deploy a bundle which includes Javascript Language into Karaf, I got
an Exception "No Script engine could be created for:js"
This may be caused by the classloader problem, it can't find the
com.sun.script.javascript.RhinoScriptEngineFactory and
com.sun.script.javascript.RhinoScriptEngine.

So does anybody have any idea how I can resolve this problem?


Thanks very much.
GangLiu


Re: Problem with pollEnrich

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Nov 7, 2012 at 9:08 PM, Babak Vahdat
<ba...@swissonline.ch> wrote:
>
>
> Am 07.11.12 09:28 schrieb "Babak Vahdat" unter
> <ba...@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: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Problem with pollEnrich

Posted by Babak Vahdat <ba...@swissonline.ch>.

Am 07.11.12 09:28 schrieb "Babak Vahdat" unter
<ba...@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.

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:

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.