You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by watcher <pa...@daly.ws> on 2010/02/21 16:17:46 UTC

Consuming a remote FTP server triggered by a route (Error)

<camel:endpoint id="ftpRepository"
uri="ftp://admin@127.0.0.1?password=pass&amp;binary=true"/>

from("activemq:queue:printers")
// set the filename in FILE_NAME header so Camel know the name of the remote
file to poll
.setHeader(Exchange.FILE_NAME, header("filename"))
.pollEnrich(ftpRepository.getEndpointUri())
.to("file://c://fileserver//output");

Here's my test.

public void testCamel() throws Exception {

		ProducerTemplate camelTemplate =
(ProducerTemplate)getApplicationContext().getBean("camelTemplate");
      	Map<String, Object> headers = new HashMap<String, Object>();
      	headers.put("filename", "AA11.txt");      	
	    camelTemplate.sendBodyAndHeaders("activemq:queue:printers",  null,
headers);
    }

If the fileserver contains 2 files 
00AA.txt
AA11.txt

The route will copy over the 00AA.txt file. It appears to copy the 1st file
or whatever file that is ordered alphabetically.

Apache Camel 2.2
Windows XP
-- 
View this message in context: http://old.nabble.com/Consuming-a-remote-FTP-server-triggered-by-a-route-%28Error%29-tp27676486p27676486.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Consuming a remote FTP server triggered by a route (Error)

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Feb 22, 2010 at 12:28 PM, watcher <pa...@daly.ws> wrote:
>
> Thanks Claus
>
> Its just that it seems to suggest that from the FTP2 wiki
>
> Consuming a remote FTP server triggered by a route
>
> from("seda:start")
>   // set the filename in FILE_NAME header so Camel know the name of the
> remote file to poll
>   .setHeader(Exchange.FILE_NAME, header("myfile"))
>   .pollEnrich("ftp://admin@localhost:21/getme?password=admin&binary=false")
>   .to("mock:result");
>

Ah well spotted. I have removed the faulty example.

There should be a ticket in JIRA somewhere to enhance pollEnrich so
you can pass in headers etc. So we may implement this in the future.
However its not super easy as the PollingConsumer API doesnt allow
this out of the box.


>
>
>
> Claus Ibsen-2 wrote:
>>
>> On Sun, Feb 21, 2010 at 4:17 PM, watcher <pa...@daly.ws> wrote:
>>>
>>> <camel:endpoint id="ftpRepository"
>>> uri="ftp://admin@127.0.0.1?password=pass&amp;binary=true"/>
>>>
>>> from("activemq:queue:printers")
>>> // set the filename in FILE_NAME header so Camel know the name of the
>>> remote
>>> file to poll
>>> .setHeader(Exchange.FILE_NAME, header("filename"))
>>> .pollEnrich(ftpRepository.getEndpointUri())
>>> .to("file://c://fileserver//output");
>>>
>>> Here's my test.
>>>
>>> public void testCamel() throws Exception {
>>>
>>>                ProducerTemplate camelTemplate =
>>> (ProducerTemplate)getApplicationContext().getBean("camelTemplate");
>>>        Map<String, Object> headers = new HashMap<String, Object>();
>>>        headers.put("filename", "AA11.txt");
>>>            camelTemplate.sendBodyAndHeaders("activemq:queue:printers",
>>>  null,
>>> headers);
>>>    }
>>>
>>> If the fileserver contains 2 files
>>> 00AA.txt
>>> AA11.txt
>>>
>>> The route will copy over the 00AA.txt file. It appears to copy the 1st
>>> file
>>> or whatever file that is ordered alphabetically.
>>>
>>
>> You cannot propagate headers when using pollEnrich. You have to set
>> the filename you want to poll on the FTP endpoint URI.
>> This is not what you want to do, so you can use a Processor to poll
>> the FTP file using Java code which allows you to current Exchange when
>> polling.
>>
>>> Apache Camel 2.2
>>> Windows XP
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Consuming-a-remote-FTP-server-triggered-by-a-route-%28Error%29-tp27676486p27676486.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Consuming-a-remote-FTP-server-triggered-by-a-route-%28Error%29-tp27676486p27685886.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Consuming a remote FTP server triggered by a route (Error)

Posted by watcher <pa...@daly.ws>.
Thanks Claus

Its just that it seems to suggest that from the FTP2 wiki

Consuming a remote FTP server triggered by a route

from("seda:start")
   // set the filename in FILE_NAME header so Camel know the name of the
remote file to poll
   .setHeader(Exchange.FILE_NAME, header("myfile"))
   .pollEnrich("ftp://admin@localhost:21/getme?password=admin&binary=false")
   .to("mock:result");




Claus Ibsen-2 wrote:
> 
> On Sun, Feb 21, 2010 at 4:17 PM, watcher <pa...@daly.ws> wrote:
>>
>> <camel:endpoint id="ftpRepository"
>> uri="ftp://admin@127.0.0.1?password=pass&amp;binary=true"/>
>>
>> from("activemq:queue:printers")
>> // set the filename in FILE_NAME header so Camel know the name of the
>> remote
>> file to poll
>> .setHeader(Exchange.FILE_NAME, header("filename"))
>> .pollEnrich(ftpRepository.getEndpointUri())
>> .to("file://c://fileserver//output");
>>
>> Here's my test.
>>
>> public void testCamel() throws Exception {
>>
>>                ProducerTemplate camelTemplate =
>> (ProducerTemplate)getApplicationContext().getBean("camelTemplate");
>>        Map<String, Object> headers = new HashMap<String, Object>();
>>        headers.put("filename", "AA11.txt");
>>            camelTemplate.sendBodyAndHeaders("activemq:queue:printers",
>>  null,
>> headers);
>>    }
>>
>> If the fileserver contains 2 files
>> 00AA.txt
>> AA11.txt
>>
>> The route will copy over the 00AA.txt file. It appears to copy the 1st
>> file
>> or whatever file that is ordered alphabetically.
>>
> 
> You cannot propagate headers when using pollEnrich. You have to set
> the filename you want to poll on the FTP endpoint URI.
> This is not what you want to do, so you can use a Processor to poll
> the FTP file using Java code which allows you to current Exchange when
> polling.
> 
>> Apache Camel 2.2
>> Windows XP
>> --
>> View this message in context:
>> http://old.nabble.com/Consuming-a-remote-FTP-server-triggered-by-a-route-%28Error%29-tp27676486p27676486.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://old.nabble.com/Consuming-a-remote-FTP-server-triggered-by-a-route-%28Error%29-tp27676486p27685886.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Consuming a remote FTP server triggered by a route (Error)

Posted by Claus Ibsen <cl...@gmail.com>.
On Sun, Feb 21, 2010 at 4:17 PM, watcher <pa...@daly.ws> wrote:
>
> <camel:endpoint id="ftpRepository"
> uri="ftp://admin@127.0.0.1?password=pass&amp;binary=true"/>
>
> from("activemq:queue:printers")
> // set the filename in FILE_NAME header so Camel know the name of the remote
> file to poll
> .setHeader(Exchange.FILE_NAME, header("filename"))
> .pollEnrich(ftpRepository.getEndpointUri())
> .to("file://c://fileserver//output");
>
> Here's my test.
>
> public void testCamel() throws Exception {
>
>                ProducerTemplate camelTemplate =
> (ProducerTemplate)getApplicationContext().getBean("camelTemplate");
>        Map<String, Object> headers = new HashMap<String, Object>();
>        headers.put("filename", "AA11.txt");
>            camelTemplate.sendBodyAndHeaders("activemq:queue:printers",  null,
> headers);
>    }
>
> If the fileserver contains 2 files
> 00AA.txt
> AA11.txt
>
> The route will copy over the 00AA.txt file. It appears to copy the 1st file
> or whatever file that is ordered alphabetically.
>

You cannot propagate headers when using pollEnrich. You have to set
the filename you want to poll on the FTP endpoint URI.
This is not what you want to do, so you can use a Processor to poll
the FTP file using Java code which allows you to current Exchange when
polling.

> Apache Camel 2.2
> Windows XP
> --
> View this message in context: http://old.nabble.com/Consuming-a-remote-FTP-server-triggered-by-a-route-%28Error%29-tp27676486p27676486.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus