You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Stefan Burkard <sb...@gmail.com> on 2013/05/16 12:40:20 UTC

Move single files (out of many) to another directory

Hi Camel-Users

I have a workflow where files are moved from an input-directory to a
processing-directory and later to an error- or target-directory. Out of the
file content messages are generated (Claim Check Pattern) and if an error
occurs during processing of the message, it is sent to an error-queue. The
file stays in the processing directory.

I am consuming the messages from the error queue with another Camel route
(this is done by an own component). This route currently dumps the
exception content from the message header to a file:

from(errorQueue)
.routeId(ROUTE_ID_ERROR) .unmarshal(jaxb)
// dump exception to a file .setHeader(Exchange.FILE_NAME, new
CreateErrorFilename()) .setBody(header(EXCEPTION_STACKTRACE)) .to("file:" +
errorFileDirectory + "?fileExist=Fail"); // how to move associated file
from processing to error-directory? ;
But as another step I need to move the associated file (filename is in
message header) from the processing-directory to the error-directory. How
can I do this?

The Camel file component is a consumer. I would need something like a
processor. Is this file move possible inside the Camel route or do I have
to implement it with plain Java and call it as a bean?

Thanks
Stephan

Re: Move single files (out of many) to another directory

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

Yeah just write a java bean to move/rename the file.

On Thu, May 16, 2013 at 12:40 PM, Stefan Burkard <sb...@gmail.com> wrote:
> Hi Camel-Users
>
> I have a workflow where files are moved from an input-directory to a
> processing-directory and later to an error- or target-directory. Out of the
> file content messages are generated (Claim Check Pattern) and if an error
> occurs during processing of the message, it is sent to an error-queue. The
> file stays in the processing directory.
>
> I am consuming the messages from the error queue with another Camel route
> (this is done by an own component). This route currently dumps the
> exception content from the message header to a file:
>
> from(errorQueue)
> .routeId(ROUTE_ID_ERROR) .unmarshal(jaxb)
> // dump exception to a file .setHeader(Exchange.FILE_NAME, new
> CreateErrorFilename()) .setBody(header(EXCEPTION_STACKTRACE)) .to("file:" +
> errorFileDirectory + "?fileExist=Fail"); // how to move associated file
> from processing to error-directory? ;
> But as another step I need to move the associated file (filename is in
> message header) from the processing-directory to the error-directory. How
> can I do this?
>
> The Camel file component is a consumer. I would need something like a
> processor. Is this file move possible inside the Camel route or do I have
> to implement it with plain Java and call it as a bean?
>
> Thanks
> Stephan



-- 
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen