In this section you can find code snippets commonly used to accomplish different tasks. The Java code can be run from a pre/postscript in any action/trigger or within an IDE, the PL/SQL code from a DB management tool.
- Print Current Concurrency and Concurrency Usage
- Print Workflow's Scheduled vs Actual Firing Time
- Remove All Failed Workflows from the Engine
- Pass Information Across to an Error Break
- Get the Email Address from a Mail Trigger
- Basic Listener that picks up the RESULT from a File Trigger
- Create a Workflow that Makes Use of all File Actions
- MFT Workflow Example
- Dynamic Java Action Listener
- Invoke a Secure REST Service
- Create and Upload a Custom Business Interval to the Repository
- Message Queuing with One-to-many Delivery Using the Audit Trail Trigger
- Read from a JMS queue using the JMS Trigger
- Monitor Workflows and Notify if a Workflow Fails
Print Current Concurrency and Concurrency Usage
This script prints out the current concurrency throttle settings, and the throttles taken up by execution on a per namespace basis. The code can be run as is from within any IDE.
Print Workflow's Scheduled vs Actual Firing Time
This PL/SQL code prints out a list of scheduled workflows, including the full namespace, the scheduled firing time and the actual firing time. This code was tested on SQL Server and can be used to put together a Report.
Remove All Failed Workflows from the Engine
This script looks for workflows that are in the FAILED state and removes them from the engine one at a time.
Pass Information Across to an Error Break
When an error occurs in Flux and an ERROR flow is followed, the Flow Context and Workflow variables are cleared before entering the flow. This example shows a way to keep (and pass on) any needed information.
Get the Email Address from a Mail Trigger
This code example grabs the RESULT.from_addresses field from the RESULT object of a Mail Trigger (in this example it's mapped to a flow context variable named from_addresses) and returns only the mail address so that it can be used in an address field of a mail action later on.
Basic Listener that picks up the RESULT from a File Trigger
This basic Listener class (to be run in a Java action) shows how to pick up the result from a File Trigger (which should be the previous action in the workflows) and prints out the list of files found. The example helps in demonstrating how to pick up flow context information and process it using the java action.
To use the listener, you'll need to compile it and then package it into a JAR file. Once that's done, place it in Flux's classpath (or point to the jar file using the workflow property Listener Classpath).
Create a Workflow that Makes Use of all File Actions
You'll need to set up the following runtime configuration variables in you runtime configuration path (or tweak the code to hardcode the values).
MFT Workflow Example
This example shows how to put together a Managed File Transfer workflow using Flux's APIs
You'll need to set up a runtime configuration file with the paths and
Dynamic Java Action Listener
This sample code shows a simple Listener class to be used with a Dynamic Java Action.
Invoke a Secure REST Service
Create and Upload a Custom Business Interval to the Repository
This sample shows how to put together a Business Interval, and exclude weekends as well as given dates. You can use the printScedule() method to test the Business Interval and see the next firing schedules.
Here is the same business calendar packaged as a workflow, with a single action, where the code is contained in a prescript. Note that in order to accomplish this, simply copy the code inside the main method to the end of prescript leaving everything else unchanged. Running this workflow with then execute this code.
Message Queuing with One-to-many Delivery Using the Audit Trail Trigger
In addition to its extensive and powerful logging capabilities, the Flux audit trail can be used as a robust, lightweight messaging platform, allowing delivery of automated notifications and even data transfer between workflows on the Flux engine.
The code below is the API example corresponding to the Message Queuing with One-to-many Delivery Using the Audit Trail Trigger example workflow.
You can download all four files of this example here: messaging_one_to_many.zip
Read from a JMS queue using the JMS Trigger
The following is unsupported example code to interact with a JMS queue from within Flux. Download the necessary jars here: jmstrigger(1).zip
Monitor Workflows and Notify if a Workflow Fails
This example listens for two Audit Trail events: Exiting Trigger On Error and Exiting Action On Error. If either one is published by an action/trigger to the Audit Trail, a mail is fired to notify a user (or group of users) about it.