You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by cwhistler <ch...@sungard.com> on 2011/07/25 21:22:15 UTC

file delete doesn't work when using filter

I have the following java route:

from("c:/temp/files?delete=true&filter=#errorFileFilter")
			.processRef("processAcceptedFiles")
			.to("c:/temp/output")
		;

The errorFileFilter reference simply returns false if the file name contains
some error file markers.

The processor simply adds up the lines in the file and adds a header and
trailer record to it:
BufferedReader inputReader = exchange.getIn().getBody(BufferedReader.class);
long idx = 0;
try
{
	while (null != (inputReader.readLine()))
	{
		idx++;
	}
}
catch(Exception e)
{
	e.printStackTrace();
}
exchange.getIn().setBody(getHdr() + "\n" +
exchange.getIn().getBody(String.class) + getEnd(idx) + "\n");

When the route ends the input file is not deleted.  it simply gets
reprocessed over and over.

So can I do this and still have the input file deleted?

I am using camel 2.7.2



--
View this message in context: http://camel.465427.n5.nabble.com/file-delete-doesn-t-work-when-using-filter-tp4632063p4632063.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: file delete doesn't work when using filter

Posted by cwhistler <ch...@sungard.com>.
yes that was the answer!!

--
View this message in context: http://camel.465427.n5.nabble.com/file-delete-doesn-t-work-when-using-filter-tp4632063p4632124.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: file delete doesn't work when using filter

Posted by Claus Ibsen <cl...@gmail.com>.
You may have to close the buffered reader you use in the processor.
It may be the OS is locking the file due this reader has not been
closed. And therefore Camel cannot delete the file.


On Mon, Jul 25, 2011 at 9:22 PM, cwhistler <ch...@sungard.com> wrote:
> I have the following java route:
>
> from("c:/temp/files?delete=true&filter=#errorFileFilter")
>                        .processRef("processAcceptedFiles")
>                        .to("c:/temp/output")
>                ;
>
> The errorFileFilter reference simply returns false if the file name contains
> some error file markers.
>
> The processor simply adds up the lines in the file and adds a header and
> trailer record to it:
> BufferedReader inputReader = exchange.getIn().getBody(BufferedReader.class);
> long idx = 0;
> try
> {
>        while (null != (inputReader.readLine()))
>        {
>                idx++;
>        }
> }
> catch(Exception e)
> {
>        e.printStackTrace();
> }
> exchange.getIn().setBody(getHdr() + "\n" +
> exchange.getIn().getBody(String.class) + getEnd(idx) + "\n");
>
> When the route ends the input file is not deleted.  it simply gets
> reprocessed over and over.
>
> So can I do this and still have the input file deleted?
>
> I am using camel 2.7.2
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/file-delete-doesn-t-work-when-using-filter-tp4632063p4632063.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/