Move and Delete operations - 6.3

Talend ESB Mediation Developer Guide

Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
Design and Development
Talend ESB

Any move or delete operation is executed after the routing has completed (post command); so during processing of the Exchange the file is still located in the inbox folder.

Let's illustrate this with an example:


When a file is dropped in the inbox folder, the file consumer notices this and creates a new FileExchange that is routed to the handleOrder bean. The bean then processes the File object. At this point in time the file is still located in the inbox folder. After the bean completes, and thus the route is completed, the file consumer will perform the move operation and move the file to the .done sub-folder.

The move and preMove options is considered as a directory name (though if you use an expression such as File Language, or Simple then the result of the expression evaluation is the file name to be used - eg if you set


then that's using the File Language which we use return the file name to be used), which can be either relative or absolute. If relative, the directory is created as a sub-folder from within the folder where the file was consumed.

By default, Camel will move consumed files to the .camel sub-folder relative to the directory where the file was consumed.

If you want to delete the file after processing, the route should be:


We have introduced a pre move operation to move files before they are processed. This allows you to mark which files have been scanned as they are moved to this sub folder before being processed.


You can combine the pre move and the regular move:


So in this situation, the file is in the inprogress folder when being processed and after it is processed, it is moved to the .done folder.

Fine grained control over Move and PreMove option

The move and preMove option is Expression -based, so we have the full power of the File Language to do advanced configuration of the directory and name pattern. Camel will, in fact, internally convert the directory name you enter into a File Language expression. So, for example, when we enter move=.done Camel will convert this into: ${file:parent}/.done/${file:onlyname}. This only happens if Camel detects that you have not provided a ${ } in the option value. So when you enter a ${ } Camel will not convert it and thus you have full control.

So, if we want to move the file into a backup folder with today's date as the pattern, we can do:


About moveFailed

The moveFailed option allows you to move files that could not be processed successfully to another location such as a error folder of your choice. For example to move the files in an error folder with a timestamp you can use moveFailed=/error/${}-${date:now:yyyyMMddHHmmssSSS}.${file:ext}.

See more examples in File Language