Customizing a FlowForce Server Job


In our earlier post titled Automate Data Mapping and Transformation with FlowForce Server, we created a job called SimpleMapAndTransform to automate data mapping with MapForce Server and creation of html reports by StyleVision Server. After the FlowForce Server job ran several times, we have accumulated many output files in the same folder we use to process input files, as well as temporary intermediate files in the workFiles folder, as seen in the image below.

FlowForce Server job execution log and working folders

In this post we will enhance the job to create more orderly results and remove unneeded temporary files.

Reorganizing Output

First, we can add more job steps inside the For each loop that processes input files to move the new .gpx and .html files created by the data mapping and transformation to the completedInput folder. These are steps 3 and 4 in the series below.

The Working-directory option in each step can also redirect output. However, the {file} variable we used to select each input file for processing contains the full path and the file name, so it’s simpler to continue to use that string and move all the output files when processing is complete.

Adding Execution steps to an existing FlowForce Server job

Our StyleVision design for the report includes a chart that is saved as a .png file separately from the main .html document. The last step in the job uses a system commandline function to move all .png files from the input folder to the completed work folder.

The commandline function lets you define any valid operating system command as a FlowForce Server job step. In this job we are still inside the For-each loop, so the .png files will move along with the associated .html document. We used a wildcard for the .png filename because the .png files do not precisely follow the naming pattern of the input documents. The wildcard pattern also works for StyleVision designs that create multiple charts for each report.

Housekeeping Job Steps

It’s good practice to clear the contents of working directories periodically. Our job uses the workFiles folder to expand the contents of the .pxf file for report rendering. The screenshot of this directory in the image at the top of this post shows the XML Schema, working files for the design, .XSLT files to render various report formats, and temporary working files.

We could add a housekeeping step after the for-Each loop in our job to clean up immediately after processing. However, FlowForce Server lets you run multiple simultaneous instances of the same job. It would be unfortunate for one instance to clear the workFiles folder while another instance is still using it!

A better solution is to define a separate housekeeping job and schedule it to run at a time when the main job is idle. Here is a shot of a very simple cleanup job for the workingFiles folder, applying the commandline function again:

Definition of a FlowForce Server Housekeeping Job

We used a wildcard to delete everything in the workFiles directory, but that option may not be appropriate in all cases. If the .pxf file contains .css stylesheets or image files that are needed by the .html document, more customized housekeeping job steps will be needed.

Job Triggers

The original SimpleMapAndTransform job is scheduled to run every 15 minutes from 8:30 to 5:00, Monday through Friday. As shown above, the cleanup job is scheduled to run once per day at 19:00, or 7:00 PM. The FlowForce Server Web interface home page shows the job schedule:

FlowForce Server Home Page Showing Active Triggers

Here’s a quick trick you can use to test a FlowForce Server job as you define it. Every job can have multiple calendar triggers. We can define a run-once trigger to immediately test a new job and schedule it for just a few seconds in the future:

Multiple Triggers for a single FlowForce Server job

We can get immediate feedback by reading the FlowForce Server Log for the details of each job step.

FlowForce Server is available for Windows, Linux, and soon for Mac OS platforms. To get started yourself, click here to download a free trial!

Tags: , , , ,
1 reply

Comments are closed.