Designing Flows

This section shows how to design your own data integrations, adapting the basic procedure outlined in Basic Flow.

Flow Elements

See the following sections to configure and connect the elements of a flow.

Components

Components provide a standard user interface for automating workflows and processing data. See the following sections to get started.

Automating Tasks with Components

Components automate operations like "read a CSV file," as shown in the example below. Set the component's properties to specify the input parameters of the operation and other behavior, like exception processing.

See Manipulating Streams below for examples of the operations components perform on streams.

Read a CSV file and write to a database with the FileGet, Mapper, and RDBPut components.

Note

If a component is not displayed in the palette, you need a license for the component. Administrators can update the license on the System page of the management console; for more information, click Help on this page.

Configuring Components

Select a component to open the properties in the inspector pane, shown below for the HTTPGet component. If a gear icon is displayed next to the component property, you can set the property dynamically, with a mapper or a property expression:

Example: Setting Properties Dynamically

The following screenshot shows the HTTPGet component's properties configured using expressions and mappings.

HTTPGet component properties.

Accessing Help for Components

To open the reference for a component, right-click the component in the palette or in the Flow window and then click Help.

The component help menu.

Starting and Ending Flows

You need to have a start and end component in a flow. See below to get started with configuring these components as the first steps to designing a flow.

See Also
  • See Triggers for the next steps, starting with creating a trigger.
  • See More Topics > Flow Control > Starting and Ending a Flow to pass input data to a flow. You can define an input stream and set flow parameters to define additional input parameters.
  • See the component reference to configure individual start and end components, for example, define cookies and headers in the HTTPStart component's properties. See the Start section for start components. See the Control section for end components.

Starting a Flow

You can use start components to process inputs from the user or the external system that is triggering the flow. See below to start a flow that executes in a transaction or processes HTTP inputs. For example, you can use an HttpStart component to process an HTTP request.

Selecting the start component type: right-click the component in the workspace and select the component type in the Replace Start Component menu.

Enabling transactions: set the start component's Begin Transaction property. The start component displays a transaction badge:

Example start components: Start, HttpStart, Start with transactions, and HttpStart with transactions

Ending a Flow or Loop

Add end components from the Control tab of the palette. You can use the various end components to define the output returned by a flow, how exceptions are handled, how transactions are handled, and when to end the execution of a loop.

Below are some examples:

The available end components

See Also
  • See Flow Control to use end components to control processing in subflows and error-processing flows.

Manipulating Streams

Components can perform the following actions on streams:

Create a Stream

Below are examples of components that read external data and create a stream that contains the data.

Components that create a stream: FileGet, RDBGet, POP3, and FTPGet.

Note

  • Looping: To support large volumes of data, some components can execute in a loop.

  • Stream variables: Components set stream variables that contain more information; for example, the FileGet component sets stream variables containing the file path, file size, etc.

    You can find the stream variables for a component listed in the reference for the component.

Transform a Stream

Below are examples of components that transform the input stream and output the resulting stream. The types of the input and output streams are often predefined.

Components that process a stream and output the results: Mapper, XSLT, MIMEDecode, and Velocity.

Use a Stream as Input

Below are examples of components that execute operations that take a stream as input:

Components that take a stream as input: FilePut, RDBPut, SimpleMail, and ZipFile

Note

Some components can handle multiple streams, such as the Zip or SimpleMail components. To use these streams, components use stream variables, like the FileName stream variable, which is returned from the FileGet component.

Format a Stream

Most components will format the output stream by automatically defining the fields so you don't have to define the fields manually. For example:

The RDBGet component executes a SELECT statement, returns a stream, and generates the field definitions of the output stream.

Execute without an Input Stream

Below are examples of components that do not require an input stream. For almost all of these cases, the input stream is passed through.

The CopyFile, DeleteFile, Log, and EXE components.

Back to Manipulating Streams.

Streams

A stream is a data structure that facilitates working with data in different formats. You can use streams to work with data in different formats as fields.

To process data, you define the stream that a component outputs. To define a stream, you select the stream's type, define the stream's fields, and set the stream's properties.

See below to create a stream definition.

See Also
  • See Streams under "More Topics" > "Flow Elements" to convert stream types or field data types, merge multiple streams, or troubleshoot date-time formats.
  • See the previous section, Manipulating Streams, for examples of the operations components perform on streams.
  • See the next section, Variables, to set stream variables, which provide additional information, in addition to the fields. Some components use stream variables as input parameters. Note that stream variables that have been declared within a stream do not change the stream definition.

Selecting the Stream Type

To select the stream type, you can click the label next to the component in the workspace. Select the stream type in the menu. The Flow Service defines the following stream types: XML, CSV, FixedLength, Record, ParameterList, MIME, HTML, Text, and Binary.

Note

You can also set a Start or SubFlow component's stream type to "Any." You can't connect these undefined-type streams to components that need to process a specific type of input stream.

Defining Fields

To define the stream's fields, click the component in the workspace and open the Stream pane in the inspector. A field definition consists of at least a name and a data type; you may need to define additional properties for the field depending on the stream type.

The table below shows the available stream types, the data that composes the stream's fields, and the properties you can set to define each field:

Stream types Stream contents Field definitions
XML Values of XML elements or XML attributes. Name, data type, repetition, node type, and display name.
CSV The data separated by a delimiter, according to the CSV format. Field name and data type
FixedLength The data separated by the field definitions. Field name, data type, starting position, length, and point position.
Record The columns of a row, as in a record processed by a relational database. Field name and data type.
ParameterList A list of parameter names and values. Field name and data type. (You can select String[] in the stream pane to define an array of strings as the data type of a field.)
MIME The stream itself -- MIME data. No field definitions.
HTML The stream itself -- HTML data. No field definitions.
Text The stream itself -- text data. No field definitions.
Binary The stream itself -- binary data. No field definitions.
See Also
  • See Stream Definitions under "More Topics" > "Flow Elements" for guides to defining the fields for a given stream type.

Setting Stream Properties

You can set the stream's properties to define how the stream's data is generated and how the generated data is used.

To set the stream properties, select the stream type in the Format property. Click the plus button to expand the list of properties for the stream. Below are the properties for the CSV component.

Below are a CSV stream's properties:

Properties for the CSV component in the stream pane of the inspector

Example Stream Definitions

Supported Field Data Types

Fields support the standard data types below:

Note

  • If you are using a ParameterList stream, you can specify an array of strings in a field by selecting String[] as the field's data type.
  • The PackedDecimal and ZonedDecimal types can be used in FixedLength streams. The Flow Service will convert PackedDecimal and ZonedDecimal to the Decimal type.

Variables

In the Flow Service, variables store values that the flow can use at run time in addition to stream data. You can map variables and use variables in expressions. You can also save run-time information. See below to define variables and find the next steps.

See Also

Defining Flow Variables

You can define flow variables on the Flow Variables tab in the Variables pane.

Properties of flow variables: name, type, default value, public access, editable, and description.

Getting and Setting Variables

You can use a mapper component to get and set variables:

See Also
  • See Mappers for a guide to creating a mapping.

Variable Types

The types of variables correspond to different scopes. You can use variables within the scope that they're valid for. You can find the scopes below. For other guides to using each variable type, see More Topics > Flow Elements > Variables.

Variable types Description
Flow variables Can be set and referenced in a running flow. You also use public flow variables as flow parameters to pass additional inputs and outputs to a flow.
Initialization When the flow begins
Valid scope Until the flow ends
System variables Can only be referenced; these variables are set by the Flow Service. System variables provide information about the environment, for example.
Local variables Can be referenced by a component running in a flow; currently, only used in the Velocity, XMLMerge, and XMLUpdate components.
Initialization When the component begins processing
Valid scope Until the component finishes processing
Mapper variables Can be set and referenced in a mapper running in a Flow. You use these within each mapping -- the processing of each row. The Mapper component sets other variable types only for a single execution of the component, for example, the first record.
Initialization When the mapper begins processing
Valid scope Until the mapper finishes processing
Stream variables Can be set and referenced only while a stream is valid. You can use these to get and set additional input and outputs for components. You can find the stream variables that a component defines in the help for the component.
Initialization When a stream is created
Valid scope Until the stream ends
External variable sets
Constants Can only be referenced (the value of the variable doesn't change). Constants can be referenced by multiple flows and projects.
Request variables Can be set and referenced by multiple flows and projects while a request is valid.

A request is the process that executes the flow, including subflow and exception-flow processing. See Designing Flows > Flow Elements > Requests for details on how requests are executed by the Flow Service.

Initialization When the request begins
Valid scope Until the request finishes
Session variables Can be set and referenced by multiple flows and projects while a session is valid.
Initialization When the session begins
Valid scope Until the session finishes
Application variables Can be set and referenced by multiple flows and projects. The value is saved outside the project, in a file named "external variable name.xvar.data".
Application variables do not have a temporary scope and are also persisted across server restarts.
Initialization When you save changes to an external variable set or initialize the application variables in the editor.
Valid scope Permanently available

Data Types

Variables use the standard data types, the same as for stream fields:

Mappers

Using a Mapper component, you can graphically map the fields of an input stream to an output stream. See the following sections for the basic workflow to add a mapper to your flow and design a mapping. You'll link together mapper functions to manipulate strings, do math, convert datetimes, etc.

Connecting and Configuring a Mapper

Drop a Mapper component into a flow window from the Control tab of the palette or the favorites section of the palette. You connect the mapper's input stream and output stream in a flow window and design the mapping in the mapping window. See the following sections to get started using the mapping window.

See Also

For more graphical workflows, such as automatically connecting fields, or to start from connecting a Mapper in a flow window, see Mapper Components in the Flow Designer user's guide.

Using the Mapping Window

Double-click the mapper to open the mapper window. Here you can link stream inputs and stream outputs, chaining together mapper functions to transform the input stream's data. See below for a walk-through of the interface.

An example mapping in the mapping window -- mapper functions like LEFT, EXTSTR (extract string), and EMBED translate input fields to output fields.

Name Descriptions
Input fields The input fields pane contains:
  • The fields of the input stream
  • The properties of the component connected to the mapper's input
  • The variables available in this scope
Mapping area Here you can link inputs to outputs. Below is the interface:
Mapper functions Drag and drop mapper functions from the mapper window's palette. Link inputs to outputs in the workspace. Configure the properties of a function in the inspector pane.
Descriptions Right-click anywhere on the workspace to insert a description.
Links Link inputs, mapper functions, and outputs into data-processing routines.
Layers Separate complex mappings into multiple layers.
Operation buttons
  • Add a layer:
  • Delete a layer:
  • Edit a layer:
  • List layers:
  • Simulate a mapping:
  • Return to the flow:
Output fields The output fields pane contains:
  • The fields of the output stream
  • The properties of the component connected to the mapper's output
  • The variables available in this scope

Adding Mapper Functions from the Palette

When you open the mapper window, the palette changes to display mapper functions. You can then use drag and drop to add mapper functions just as you would drag and drop components in the main workspace.

Connecting Input Parameters

In the mapper window, you can connect input fields to a mapper function to provide the function's input parameters; connect the function's return value to the output stream or to the next function. Select the function to configure the function's properties in the inspector pane.

マッパー関数

Note

  • You can also change the order of the inputs. The order of the inputs is important for some functions. Consider the CONCATENATE function, which combines strings in the order that you specify them.
  • Some functions output multiple return values.
  • Functions are executed once for each record.

Setting Mapper Function Properties

You can enter property values in the inspector. Some properties can be set dynamically. If the icon is displayed next to the property, you can set the property by linking an input field to the mapper function in the mapping area. You need to link the input field in the necessary order.

For example, the LEFT string function's Count property is Input2. Input1 is the string to return the leftmost characters from.

To change the order of the inputs, click the box for the input in the inspector's Link section and select a field you linked.

マッパー関数

Or, right-click the mapper function in the mapping area and click Change Input Order. When you set the corresponding ordered parameter, the property displays the property-replaced icon.

See Also
To find the input order that a mapper function defines, see the help for the mapper function in the Mapper Functions reference.

Example Mappings

See below for more examples of how to connect mapper functions:

Predefined Inputs

The function definition can specify a fixed set of input values. For example: LEFT, TABLE, MULTIPLY, and LEN, shown below. Some functions also accept an alternative set of inputs. For example: the LEFT function can accept an optional Count parameter.

The mapping area populated with a list of functions that define a set number of inputs.

No Inputs

These functions do not accept any inputs, for example, the CONST, UUID, NOW, and RAND functions shown below.

マッパー関数

Undefined Inputs

The number of inputs to these functions can vary, for example, SUM, MAX, AND, CONCAT, NULLCHECK, and JAVAINTERPRETER.

Mapper functions that can accept a variable number of inputs: SUM, MAX, AND, CONCAT, NULLCHECK, and JAVAINTERPRETER.

One Output

Most mapper functions output only one value.

Multiple Outputs

These functions can output multiple values, for example, the SPLIT string function, FILENAME, JAVAINTERPRETER, and date-time functions like DATESPLIT.

These functions' properties define the number of outputs -- except for the SPLIT function. To configure a function's output, see the property descriptions in the function's documentation: right-click the function and click Help.

A list of functions with multiple outputs: SPLIT, FILENAME, JAVAINTERPRETER, and DATESPLIT.

Creating Subfunctions

You can use the following mapper functions to create subfunctions:

See Also

Connections

See below for an overview of managing connection definitions to external systems. The overview walks through connecting to a database as an example.

See Also

Connecting to External Systems

You can create a connection definition to connect to external systems like databases or data sources using internet protocols like HTTP.

Type of Data Source Component
Database RDB
Internet HTTP, FTP, SMTP, POP3, IMAP4, AWS, kintone
Others Queue, JNDI

Managing User and System Connections

You can create user connections in the Flow Designer -- connections that only the owner user can use. You can manage the connections your user account has access to in the tree pane. See Connections in the Flow Designer user's guide for procedures.

You can create system or user connections in the management console. Create and manage connections on the Settings > Connection page.

Creating and Testing a Connection

You can create and test connections in the Flow Designer or management console.

Flow Designer

Create a connection in the connection pane:

Connection definitions listed by type in the connection pane

  1. Create the connection: after you connect to the server, click the Create Connection button in the toolbar of the connection pane, then select the connection type.
  2. Configure the connection: select the connection in the connection pane and then enter the connection properties in the inspector.
  3. Test the connection: right-click the connection and then click the Test Connection button.

Management Console

Manage connections on the Settings > Connection page of the management console.

Connecting from a Component

  1. Drop in the component from the palette onto the workspace.

    The Database tab.

  2. Select the component in the workspace to display the properties in the inspector. Select the connection definition in the Connection list.

    Properties of a component in the inspector

Using Connection Pooling

To pool connections to a data source, select the connection definition's Use Connection Pool option. Components using the same connection with the same name in the same request will use the same connection pool.

To configure the connection pool, set the following in the management console, under Settings > Services > Flow > Flow Engine:

See Also
See the More Topics section for Connections to configure and manage connection pools.

Requests

How Requests are Executed

A request is the processing of a flow, from the start to the end; the request includes the processing of SubFlow and NextFlow components. A request is executed in a single thread.

Starting a Flow in a Separate Request

You can use the components on the Schedule tab of the palette, such as timer components, or the ParallelSubflow component on the Control tab to execute a flow in a separate request. The new request will be assigned to another thread.

See Also
  • Using flow-control components: See Flow Control to use the Timer, SubFlow, and NextFlow components with flow control structures, like loops.

Sessions

Sessions store information at run time across requests. Requests can access session data using the session ID. Sessions manage the following information:

Execution user The user who is executing the flow
Session variables Variables that can be set and referred to across flows that are running within the same session
Connection information The connections that the flow is using (for example, database connections)

Using Sessions

Sessions can save status information. For example, a web application might save session data that specifies a user's status as logged in or logged out.

If the Session ID of a request is the same as a session that already exists, the existing session will be used for the request. If the Session ID does not exist, a new session will be created.

Opening and Closing Sessions

If you set the Session property of a flow to "Close," the session will be closed when the request finishes. If you set the property to "Keep," the session continues to exist until the session times out, even after the flow finishes.

Note

The Flow Service automatically sets the Session property to "Keep" in some cases; for example, if you add an external variable set that defines session variables.

Configuring Sessions

Click Help in the management console for more information on configuring sessions:

Transactions

Some, but not all, components use transactions. You can also commit or roll back all the transactions in a flow as a single transaction set the start component's BeginTransaction property to true.

See Flow Elements > Transactions in "More Topics" to use transactions in the Flow Service.

Checkpoints

You can use Checkpoint components to retry failing flows and monitor running flows. Checkpoint components save execution data and output status information.

The Flow Service automatically retries the flow from the last Checkpoint if an error occurs, reusing the data that the Checkpoint has saved. You can monitor Checkpoints' status and manually re-execute flows in the management console and other tools like the flow-ctrl CLI, Flow Service API, and SDK.

See Checkpoints in More Topics > Flow Elements to configure checkpoints. See Failover Using Checkpoints in More Topics > Flow Elements to automatically retry flows on another server.

External Project Files

You can use external project files to simplify flow development. By saving flow data and flow objects into files outside the .xfp project file, you can reuse flow elements across projects. You can save variables, stream definitions, and function collections in the following 3 files:

External Variable Sets

Use external variable sets to define constants, request variables, session variables, and application variables. External variable sets persist these variables in .xvar files located in the user's home folder; by referencing an .xvar file in your flows, you can share variables across projects and flows.

See External Variable Sets under More Topics > Flow Elements for more notes on using external variable sets, such as how to search external variable sets.

Create and Manage External Variable Sets

See External Variable Sets in the Flow Designer user's guide.

Declare an External Variable Set in Your Flow

To use a variable from an external variable set in your flow, drag and drop the External Variable Set icon from the tree pane onto the workspace.

Function Collections

A function collection is an .xmp file that contains one or more SubFunctions. SubFunctions provide a way to create subroutines that you can reuse across mappings. You can reference function collections in multiple projects and share function collections with your team.

See the following sections to get started. See Function Collections in the Flow Designer user's guide. for other tasks and step-by-step procedures.

Create a SubFunction

Follow the steps below to create a SubFunction in a new function collection:

  1. Right-click a folder in the tree pane and click New Function Lib.
  2. Define the SubFunction's mapping.

Add a SubFunction to a Mapping

You can drag and drop SubFunctions from the tree pane onto the mapping area. Or, add a SubFunction icon from the Control tab of the palette and then set the SubFunction's Function Name property to the name of a SubFunction in a function collection.

Stream Definition Sets

You can persist a set of stream definitions in .xsf files. Using .xsf files, you can keep the stream definitions for multiple components in sync.

A stream definition consists of a stream's properties and data fields. For guides to creating and using stream definition sets, see Stream Definition Sets in the Flow Designer user's guide.

Memo

As opposed to external variable sets and function libraries, .xsf files are only used at design time, to facilitate creating flows -- these are not not used when the flow runs.

Flow Control

See the following sections for introductions to the flow control components and links to more information:

See Also

Loops

See below to create and execute loops in the Flow Service:

When to Use Loops

You can use loops to process large result sets one row at a time, rather than processing the whole result set in memory at once, reducing the footprint on the physical memory available. For example, the RDBGet component can loop over each row returned from a SELECT statement or pass the whole result set to another component.

Starting Loops

To start a loop, drop in a component that can loop. Below are some examples:

A list of example components you can start a loop with: LoopStart, RDBGet, CSVGet, TextSplitLoop, POP3, and Mapper.

Executing Loops

When a component in a flow starts a loop, the flow returns to that component until the flow reaches a LoopEnd, ParallelSubFlow, or a component that ends the flow.

Note

During parallel branching the execution process for loops changes from the above:

  • You can't use loops for all components: when used in a loop, components that use parallel branching will throw a run-time error.
  • You can't use a loop while you're processing routes in parallel: A loop will not begin if a component in the flow has a pending execution status. You need to have closed the loop using the LoopEnd component or the ParallelSubFlow component on one parallel route to execute the loop.

Conditional Branching

You can use conditional branching with components that have a connector on the right side. These components are processed as follows: according to the given condition, the component will output a stream either from the right connector or from the bottom connector.

Example Components

Some uses of conditional branches: merge branches or branch depending on the index, whether an error exists, the result of validation, or a condition.

Combining Branches

You can use the BranchEnd component to output one of several input streams based on a condition.

Using a Mapper after Combining Branches

You can use a mapper after a BranchEnd component if the input stream definitions are the same. Two stream definitions are the same if the streams have the same set of properties and fields.

See below for an example of the component's behavior and additional usage notes. In the example, a BranchEnd component outputs a stream from linked RDBGet components.

An example flow that uses a BranchEnd component to merge the record-type output streams from two RDB components.

The BranchEnd component's output stream could be either the "any" type or the record type.

Note

Update the mapper's input stream after you change the input streams for the BranchEnd component: right-click the BranchEnd component and then select Refresh Stream Definition.

Ending Branches

You can use one of the end components to end a branch's flow. But, a flow cannot return multiple output streams; to avoid an error, you need to meet this requirement.

Consider the example below: the BranchStart component will execute only one of the EndResponse components, based on the success or failure of the specified condition. But, if you configure the FileGet component to use looping, an error will occur if both routes are executed.

A flow that returns the output of an XML file; a BranchStart component redirects the output of a FileGet component to one of two EndResponse components.

Parallel Branching

You can use parallel branching to process a component's output stream along parallel routes: connect the component's output stream to multiple components. The parallel routes are processed according to the order of execution. Click the component to display the order of execution for its output streams.

A mapper component whose output stream is processed by two mapper components, using paralleling.

Order of Execution

The flow follows each route in a series of parallel routes until the route ends, then it switches to the next route in the order of execution. Parallel routes can end in the following ways:

Ending Parallel Streams

To avoid an error, be sure not that the flow only returns one output stream; the routes of a flow must resolve to one EndResponse component.

コンポーネント

SubFlow

You can use a SubFlow component to reuse a flow as a subroutine. SubFlow components invoke a subflow from a parent flow. The subflow's data-processing procedure executes as a subroutine of a parent flow.

To add a subflow to your flow, you can drag and drop a flow from the tree pane onto the workspace. Or, add a SubFlow component from the Control tab of the palette and set the component's Flow property.

See the SubFlow section in "More Topics" to pass inputs to a subflow, get the results of processing from a subflow, and do other tasks to configure subflows.

NextFlow

You can end a flow with the NextFlow component to call another flow after the flow finishes processing. Add a NextFlow component from the Control tab of the palette.

See the NextFlow section in "More Topics" to select the next flow with a Mapper or execute the next flow in a transaction.

Timer Components

You can use various timer components to start a new flow on a time or interval. The flow runs in another thread; at the same time, the caller flow continues running -- the caller flow doesn't wait for the new flow to finish.

You can add a timer component from the Schedule tab of the palette. See the Schedule section under the component reference for more information.

Parallel SubFlow Components

You can use ParallelSubFlow components to effectively process data on a multi-CPU or multicore server. You can add a ParallelSubFlow after a component that uses loop processing; for each loop, the ParallelSubFlow component starts a new request that's processed in parallel.

Add a ParallelSubFlow component from the Control tab of the palette. To configure ParallelSubFlow components, see the component reference.

See Also
See Threading and Execution under "More Topics" > "Flow Service Architecture" to follow the execution of a parallel subflow.

Error Processing

When a component can't continue to process or fails to process, the component throws an exception. You can do nothing, ignore the error, or specify post-processing to handle the error in the exception flow.

See More Topics > Processing Errors for guides to configure postprocessing in the exception flow.