FME Version
Files
Introduction
It's often useful to know the number of features written by a workspace in an FME Flow Automation so that the information can be used downstream, for example, in an email. The FME Flow Automations writer allows you to pass the total features written, and any other attributes, to an Automation.
This article is an extension of Routing Data Between Workspaces in Automations. Please review that article for more detailed steps on working with FME Workbench and the FME Flow Automations writer.
Step-by-Step Instructions
1. Create a workspace with a Feature Writer
For this article, we’ll be using the workspace TrafficWorkOrdersToProcess.fmw. It can be found in the Files section near the top of this article.
Let’s take a look at the workspace. It simply reads a csv file of work orders (Traffic_Signal_Work_Orders.csv) and writes any that have yet to be processed to a SpatiaLite database using a FeatureWriter.
Open the FeatureWriter parameters. It outputs a feature through the Summary port that summarizes what was written, including a count of the total features written.
2. Connect the FeatureWriter to an FME Flow Automations writer
The FeatureWriter’s Summary output port is connected to an FME Flow Automations writer. The summary feature with the _total_features_written will be passed to an Automation that uses this workspace, so that it can be used downstream in an automation.
3. Test and publish to FME Flow
The FeatureWriter is already configured to create the SpatiaLite DB in the Data resource folder on FME Flow. To test the workspace before uploading it, set the FME_SHAREDRESOURCE_DATA parameter to a location on your local computer. Once published to FME Flow, the local folder set here will be ignored.
Run the workspace and confirm it runs without error, then click Publish to upload the workspace to FME Server to a repository of your choice.
Upload the Traffic_Signal_Work_Orders.csv file to the Data Shared Resource folder on FME Flow. This is the location where the workspace is looking for the input file.
Leave the default Job Submitter Service checked and publish.
4. Create the FME Flow Automation
Log in to FME Flow and from the menu, click Automations > Build Automation.
For demonstration purposes, we’ll use a manual trigger. In the Manual Trigger settings, disable Prompt for JSON on Trigger.
Connect an action to the Manual Trigger and set it to Run a Workspace. Choose the TrafficWorkOrdersToProcess.fmw workspace and click Apply.
Notice that there is an output port on WorkOrders output port on the action. This output port exists because of the FME Flow Automations writer in the workspace. The WorkOrders feature contains the _total_features_written attribute that is output from the FeatureWriter’s Summary output port, as shown earlier.
Save the Automation as Unprocessed Work Orders.
Add an External Action and choose Email (send) as the action. You can click Load Template to pick from popular services. In this case, the Gmail template was used. Enter the required Email action parameters up to the Email Subject.
Let’s include the total features written in the Email Subject. Click the drop-down arrow and choose Text Editor.
Use the Text Editor to create a subject line that includes the _total_features_written attribute passed from the workspace. Click OK and the Apply to save the Email Action. Save the Automation.
5. Test the automation
The automation is now ready to test! Click Start Automation.
Click the Trigger button to trigger the Automation.
You should see a message that the automation has been triggered.
After a short wait, you should receive an email with the number of total unprocessed work orders written.
If you do not receive an email, check the Automation’s Log File for errors, like incorrect email account credentials.
Comments
0 comments
Please sign in to leave a comment.