You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Nishtha Rai <ni...@gmail.com> on 2021/03/10 10:39:32 UTC

CamelFileNameProduced header not coming when there is no data in the file

Hi Team,

We have created a simple camel route -

@Override@Override public void configure() throws Exception {
from("file://C:/in/?fileName=Input_UTF8.txt") .process(exchange ->

{           System.out.println("Headers after in: "+
exchange.getIn().getHeaders());     }

)         .onCompletion()           .process(exchange -> {
 sendFooter(exchange);                 System.out.println("Headers after
Footer: "+ exchange.getIn().getHeaders());           })
 .end()                      .process(exchange -> {  sendHeader(exchange);
System.out.println("Headers after header: "+
exchange.getIn().getHeaders());        })
.split(body().tokenize(lineSeperator)) .streaming()
.to("file://C:/out/?fileName=Output.txt&fileExist=Append")
.process(exchange -> {           System.out.println("Headers after each
record: "+ exchange.getIn().getHeaders());     }); } private void
sendHeader(Exchange exchange) { ProducerTemplate template =
getContext().createProducerTemplate();
template.sendBodyAndHeaders("file://C:/out/?fileName=Output.txt&fileExist=Append","header1,header2",exchange.getIn().getHeaders());
   } private void sendFooter(Exchange exchange) { ProducerTemplate template
= getContext().createProducerTemplate();
template.sendBodyAndHeaders("file://C:/out/?fileName=Output.txt&fileExist=Append","footer",exchange.getIn().getHeaders());
}



CamelFileNameProduced header is not coming when there is no data in the
file (header and footer will be there) although it is creating a file in
the destination directory.

We need the  CamelFileNameProduced header even in case of only header and
footer in the output file and no data in the file.

Could you please help on this.

Thanks & Regards

Nishtha Rai