Please enable JavaScript to view this site.

Altova FlowForce Server 2020 

This example shows you how to monitor a directory for changes with the help of a file system trigger created in FlowForce Server (see also File System Triggers). Whenever a new XML file is added to the directory, FlowForce Server executes a mapping job that takes the XML file as input parameter. The output of the mapping job is then moved to an archive directory.



Required licenses: MapForce Enterprise or Professional edition, MapForce Server or MapForce Server Advanced Edition, and FlowForce Server

FlowForce Server is running at the configured network address and port (see Setting the Network Address and Port)

You have a FlowForce Server user account with permissions to one of the containers (by default, the /public container is accessible to any authenticated user).

The mapping job created in this example copies files from one directory to another. Therefore, on the operating system where FlowForce Server runs, ensure that both directories exist and that you have rights to create files in both directories (this example uses the C:\temp and C:\archive directory).


Demo files used

ShortApplicationInfo.mfd — the MapForce mapping from which the FlowForce Server job will be created

ApplicationsPage.xml — the XML instance file to be supplied as input to the mapping.


Both files are available at the following path on the machine where MapForce is installed: <Documents>\Altova\MapForce2020\MapForceExamples\.


What the mapping does

The MapForce mapping used in this example (ShortApplicationInfo.mfd) is illustrated below. From a FlowForce Server perspective, the important thing is that the mapping takes an XML file as input, and produces another XML file as output.


This mapping essentially converts an XML file (ApplicationsPage.xml) to a different schema and saves it as ShortInfo.xml. The mapping is relatively easy to understand by looking at the topmost connection: for each Item found in the source, it creates an Info item in the target. The other connections are used to copy values from the respective child items. Of particular interest is the dotted connection; in MapForce, this connection is called "Source-driven (Mixed Content)" and it is used because SubSection contains mixed content.



Notice the names of the source and target XML schemas are SectionedPage and ShortInfo, respectively. As you will see further below, the FlowForce job will have an input and output parameter with the same name, after the mapping is deployed to FlowForce Server.


Deploying the mapping to FlowForce Server

The mapping ShortApplicationInfo.mfd does not need any special preparation before it is deployed to FlowForce Server. Since both the source and target components are XML files, they will be included automatically in the package deployed to FlowForce Server.


To deploy the mapping to FlowForce, open it in MapForce and run the menu command File | Deploy to FlowForce Server.


If FlowForce Server runs on a different host and port, change the connection details above accordingly, see Defining the Network Settings.


Creating the directory polling job

After the mapping is deployed to FlowForce Server, the browser opens and loads the job creation page. As illustrated below, the first execution step is created automatically and it calls the mapping function deployed previously. Notice that the input parameter has the same name as the source MapForce component (SectionedPage), while the output parameter has the same name as the target component (ShortInfo).



Configure the job as follows:


1.In the Working-directory box, enter the path to the working directory applicable to this step. This example uses C:\temp as working directory.

A working directory is a parameter required by execution steps if the job needs a location to unpack any input files or save output files. FlowForce Server also uses the working directory to resolve any relative paths that occur during step execution. When asked to provide a working directory, you should supply a valid path on the operating system where FlowForce Server runs. If you do not supply a working directory when creating the step, FlowForce Server uses a temporary directory.

2.Under Triggers, click new Filesystem trigger. Notice that FlowForce Server automatically adds a new triggerfile parameter under Input Parameters. You will need to refer to this parameter in a subsequent step.


3.Set the following trigger values:


Check: Modified Date

File or directory: c:\temp\*.xml

Polling interval: 60 seconds


4.Under Execution Steps, supply the triggerfile parameter as input value to the SectionedPage parameter. To do this, click the ff-setTo button next to the SectionedPage parameter, and then select triggerfile. As a result, the value of the SectionedPage parameter changes to {triggerfile}. The curly braces denote a FlowForce expression and should not be removed.


With the configuration done so far, the trigger will fire whenever ApplicationsPage.xml is copied into the working directory. However, since the trigger uses a wildcard (*.xml), it would be fired also when any other XML file changes inside the directory, including the mapping output itself (ShortInfo.xml). This is not the intended behaviour and could cause errors; therefore, let's add a second step that will move the generated output file to a new directory. Alternatively, you could rename the trigger to c:\temp\ApplicationsPage.xml (in this case, a second step is no longer necessary).


To add the step which moves the output to a new directory, do the following:


1.Add a new execution step, immediately after the previous one.

2.Configure the step as follows (note that the source and destination fields are case-sensitive):


Execute function: /system/filesystem/move

Source: c:\temp\ShortInfo.xml

Destination: c:\archive

Working directory: c:\temp


Finally, add your operating system credentials with which the job will be executed:


1.Under "Credentials", select an existing credential record or specify a local credential (see Credentials).

2.Click Save.


Running the job

You can now test the job by copying the file ApplicationsPage.xml to the working directory. When you do this, FlowForce Server executes the mapping job and copies the resulting output file to the archive directory.


To see whether the job executed successfully, refer to the job log (see Viewing the Job Log).

© 2020 Altova GmbH