You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Kaver <le...@ngs.ru> on 2009/08/16 16:42:51 UTC

File component: set file name

Hello. I use Apache Camel 1.6.1.

I've a route for writing messages from Processor to file:
from("direct:text-file").to("file:///tmp/sts?noop=true");

In Processor I call:
ProducerTemplate template = exchange.getContext().createProducerTemplate();
template.sendBody("direct:text-file", event.toString());

This works fine except of file name, they are like this:
/tmp/sts/ID-dru-amilo/40825-1250431613877/1-0

I want to set a file name manually, to have them like:
/tmp/sts/file.txt

At http://camel.apache.org/file.html written:
// set the output filename using java code logic, notice that this is done
by setting
// a special header property of the out exchange
exchange.getOut().setHeader(Exchange.FILE_NAME, "report.txt");

When I try this:
template.sendBodyAndHeader("direct:text-file", event.toString(),
Exchange.FILE_NAME, "event.log");

I got:
RequestProcessor.java:97: cannot find symbol
symbol  : variable FILE_NAME
location: interface org.apache.camel.Exchange
                            Exchange.FILE_NAME, "event.log");

What is wrong?
-- 
View this message in context: http://www.nabble.com/File-component%3A-set-file-name-tp24994188p24994188.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: File component: set file name

Posted by Kaver <le...@ngs.ru>.
Thank you for your reply, it is my fault, I re-read documentation and found
this constant. But for 1.6.1 it is not org.apache.camel.file.name, but it is
FileComponent.HEADER_FILE_NAME.

Thank you!


Claus Ibsen-2 wrote:
> 
> Hi
> 
> The problem is that some of the examples on the wiki page are
> extracted from real unit tests from the SVN and Apache just grabs from
> trunk and thus Camel 2.0
> where as it should grab it from the 1.x branch.
> 
> So use this header instead
> org.apache.camel.file.name
> 
> I believe there is a constant for it on FileComponent in Camel 1.x
> 

-- 
View this message in context: http://www.nabble.com/File-component%3A-set-file-name-tp24994188p24999828.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: File component: set file name

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

The problem is that some of the examples on the wiki page are
extracted from real unit tests from the SVN and Apache just grabs from
trunk and thus Camel 2.0
where as it should grab it from the 1.x branch.

So use this header instead
org.apache.camel.file.name

I believe there is a constant for it on FileComponent in Camel 1.x



On Sun, Aug 16, 2009 at 4:42 PM, Kaver<le...@ngs.ru> wrote:
>
> Hello. I use Apache Camel 1.6.1.
>
> I've a route for writing messages from Processor to file:
> from("direct:text-file").to("file:///tmp/sts?noop=true");
>
> In Processor I call:
> ProducerTemplate template = exchange.getContext().createProducerTemplate();
> template.sendBody("direct:text-file", event.toString());
>
> This works fine except of file name, they are like this:
> /tmp/sts/ID-dru-amilo/40825-1250431613877/1-0
>
> I want to set a file name manually, to have them like:
> /tmp/sts/file.txt
>
> At http://camel.apache.org/file.html written:
> // set the output filename using java code logic, notice that this is done
> by setting
> // a special header property of the out exchange
> exchange.getOut().setHeader(Exchange.FILE_NAME, "report.txt");
>
> When I try this:
> template.sendBodyAndHeader("direct:text-file", event.toString(),
> Exchange.FILE_NAME, "event.log");
>
> I got:
> RequestProcessor.java:97: cannot find symbol
> symbol  : variable FILE_NAME
> location: interface org.apache.camel.Exchange
>                            Exchange.FILE_NAME, "event.log");
>
> What is wrong?
> --
> View this message in context: http://www.nabble.com/File-component%3A-set-file-name-tp24994188p24994188.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus