Question

Is there any way to set multiple destinations/targets in YADE?

Answer

Within limits. YADE is presently not able to work as an Enterprise Service Bus (ESB). But multiple targets and sources, like an ESB, are on the wish lists of some users. The idea is to get the data from a source (or multiple sources) and transfer them to e.g. an FTP server, an SMTP server and to an archive folder on a different FTP server. This will require a new kind of configuration and the ini-file approach currently used in YADE is not very helpful for this kind of customising. We will be changing to a xml configuration files in the future.

Transfer to different destinations on the same server

You can, however, copy or move files to different destinations on the same server. For example, if you want to copy a file after transfer to an additional folder then you can use the post_command and pre_command parameters. These parameters are available for the source and the target. The command string, defined there, will be executed for each transferred file.

An example for Linux in Java:

 objOptions.Target().Post_Command.Value("echo 'File: $TargetFileName' >> t.1;cat $TargetFileName >> t.1;rm -f $TargetFileName");
 objOptions.Target().Pre_Command.Value("touch $TargetFileName");

The Post_Command is used in order to execute a command string that will

  1. append the text "File: ..." to a file named t.1
  2. append the content of the current target file to the t.1 file
  3. remove the current target file

$TargetFileName is a variable name (place holder) for the current target file. $SourceFileName is the name of the file from the source that is currently transferred.

More examples:

After transfer of a source file the source file should be moved to an archive folder:

 source_PostCommand=mv $SourceFileName  ...

Another way to rename/move (but not copy) on source and/or target is to use the replace and replacing parameters:

 objOptions.Source().replacing.Value("(.*)(.txt)");
 objOptions.Source().replacement.Value("/SAVE/\\1_[date:yyyyMMddHHmm];\\2");

or in ini-file notation:

 Source_replacing=(.*)(.txt)
 Source_replacement=/SAVE/\1_[date:yyyyMMddHHmm];\2

All files on source with .txt extension will be moved to the /SAVE folder and the filename will be extended by a timestamp.

Using YADE this way you can move or copy files in the source or target folder to any other destination that can be accessed from YADE.