You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ebinsingh <eb...@VerizonWireless.com> on 2011/12/06 16:38:22 UTC

using header.CamelFileName in file

Hi All,

For some reason the expression "${header.CamelFileName}" is not getting
recoganised.
I am tring to set my own file name to the output file.

Please can you ponit out if am missing something here.

		ProducerTemplate prod = exchange.getContext().createProducerTemplate();
		for(ParsedDataBean data: tdrData){
			//log.info("The size of processed data: "+data.getFileName());
			exchange.getIn().setBody(data.getData());
			String fileName = data.getFileName();
			exchange.getIn().setHeader(Exchange.FILE_NAME,fileName);
			if(data.getSize() < batchSize){
				log.info("The Batch of "+batchSize+" records is NOT complete");
				exchange.getIn().setHeader(Exchange.BATCH_COMPLETE, false);
				prod.sendBody("seda:tempQueue",exchange.getIn().getBody());
			} else {
				log.info("The Batch of "+batchSize+" records is complete");
				exchange.getIn().setHeader(Exchange.BATCH_COMPLETE, true);
			
prod.sendBody("file:C:\\camelProject\\data\\outbox\\tdr?fileName=${header.CamelFileName}.xml",
exchange.getIn().getBody());
			}
		}

Thanks & regards,
Ebe

--
View this message in context: http://camel.465427.n5.nabble.com/using-header-CamelFileName-in-file-tp5052452p5052452.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: using header.CamelFileName in file

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

Seems very odd what you are doing.

For sending data to a file endpoint and specify a name of the file to
write all you have to do


ProducerTemplate prod = exchange.getContext().createProducerTemplate();
Object data = ...
String filename = "hello.txt";

prod.sendBodyAndHeader("file://somedir", data, "CamelFileName", filename);


On Tue, Dec 6, 2011 at 4:38 PM, ebinsingh
<eb...@verizonwireless.com> wrote:
> Hi All,
>
> For some reason the expression "${header.CamelFileName}" is not getting
> recoganised.
> I am tring to set my own file name to the output file.
>
> Please can you ponit out if am missing something here.
>
>                ProducerTemplate prod = exchange.getContext().createProducerTemplate();
>                for(ParsedDataBean data: tdrData){
>                        //log.info("The size of processed data: "+data.getFileName());
>                        exchange.getIn().setBody(data.getData());
>                        String fileName = data.getFileName();
>                        exchange.getIn().setHeader(Exchange.FILE_NAME,fileName);
>                        if(data.getSize() < batchSize){
>                                log.info("The Batch of "+batchSize+" records is NOT complete");
>                                exchange.getIn().setHeader(Exchange.BATCH_COMPLETE, false);
>                                prod.sendBody("seda:tempQueue",exchange.getIn().getBody());
>                        } else {
>                                log.info("The Batch of "+batchSize+" records is complete");
>                                exchange.getIn().setHeader(Exchange.BATCH_COMPLETE, true);
>
> prod.sendBody("file:C:\\camelProject\\data\\outbox\\tdr?fileName=${header.CamelFileName}.xml",
> exchange.getIn().getBody());
>                        }
>                }
>
> Thanks & regards,
> Ebe
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/using-header-CamelFileName-in-file-tp5052452p5052452.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/