Workflow Bridge Example Real-Time to Real-Time Scenario with Load Balancing(3.0)

This section will show an example of a scenario where a real-time forwarding workflow will split the execution of UDRs between three real-time collection workflows depending on the incoming data. Each collection workflow will add information and send back the consumeCycleUDR to the real-time forwarding workflow for further execution. The following configurations will be created:

  • An Ultra Format
  • A Workflow Bridge profile
  • A Workflow Bridge real-time forwarding workflow
  • A Workflow Bridge real-time collection workflow

Define an Ultra Format

A simple Ultra Format needs to be created in order to forward the incoming data and enable the collection workflows to populate it with more information. For more information about the Ultra Format Editor and the UFDL syntax, refer to the Ultra Format Management User's Guide.

Create an Ultra Format as defined below:

internal myInternal  {
    string    inputValue;
    string    executingWF;
};

Define a Profile

The profile is used to connect the forwarding workflow towards the three collection workflows. See Workflow Bridge Profile for information how to open the Workflow Bridge profile dialog.

In this dialog, the following settings should be made:

  • The  Send Reply Over Bridge is selected which means that all ConsumeCycleUDRs will be returned to the Workflow Bridge forwarding agent.

  • Force serialization is not used since there will be no configuration changes during workflow execution.

  • The Workflow Bridge real-time collection agent must always respond to the WorkflowState UDRs. The Response Timeout (s) has been set to "60" and this means that the Workflow Bridge real-time forwarding agent that is waiting for a WorkflowState UDR reply will timeout and abort (stop) after 60 seconds if no reply has been received from the real-time collection workflow.

    Enter the appropriate timeout value to set the timeout for the Workflow Bridge real-time forwarding agent.

  • The Bulk Size has been set to "0". This means that the UDRs will be sent from the Workflow Bridge real-time forwarding agent one by one, and not in a bulk. Enter the appropriate bulk size if you wish to use bulk forwarding of UDRs.

  • The Bulk Timeout (ms) has been set to "0" since there will be no bulk forwarding. Enter the appropriate bulk timeout if you wish to use bulk forwarding of UDRs. Bulk timeout can only be specified if the bulk functionality has been enabled in the Bulk size setting.

  • Since the UDRs in this example will be split between three different workflows, the Number of Collectors has been set to "3".

Create a Real-Time Forwarding Workflow

In this workflow, a TCP/IP agent collects data that is forwarded to an Analysis agent. The Analysis agent will define the receiving real-time collection workflow before the ConsumeCycleUDR is sent to the Workflow Bridge forwarding agent. The Workflow Bridge forwarding agent will distribute the UDRs to the correct collection workflow and forward the returning ConsumeCycleUDR to another Analysis agent for further execution.

The workflow consists of a TCP/IP agent, an Analysis agent named Analysis, a Workflow Bridge real-time forwarding agent named Workflow_Bridge_FW and a second Analysis agent named Result.

TCP/IP

TCP/IP is a collection agent that collects data using the standard TCP/IP protocol and forwards it to the Analysis agent.

Double-click on the TCP_IP agent to display the configuration dialog for the agent:

In this dialog, the following settings have been made:

  • Host  has been set to "10.46.20.136". This is the IP address or hostname to which the TCP/IP agent will bind.

  • Port  has been set to "3210". This is the port number from which the data is received.

  • Allow Multiple Connections  has been selected and  Number of Connections Allowed  has been set to "2". This is the number of TCP/IP connections that are allowed simultaneously.

Analysis

The Analysis agent is an Analysis agent that receives the input data from the TCP/IP agent. It defines which real-time collection workflow should be chosen and forwards the ConsumeCycleUDR to the Workflow_Bridge_FWD agent. Double-click on the Analysis agent to display the configuration dialog.


Example - APL code

consume { 
    wfb.ConsumeCycleUDR ccUDR = udrCreate(wfb.ConsumeCycleUDR); 
    WFBridge.myFormat.myInternal data = 
    udrCreate(WFBridge.myFormat.myInternal); 
    data.inputValue = baToStr(input); 
    debug("First character is: " + 
    strSubstring(data.inputValue,0,1)); 
    if (strStartsWith(data.inputValue,"1") || 
    strStartsWith(data.inputValue,"2")) { 
         int wfId; 
         strToInt(wfId,strSubstring(data.inputValue,0,1)); 
         ccUDR.LoadId = wfId; 
    } else { 
         ccUDR.LoadId = 3; 
    }
    ccUDR.Data = data; 
    udrRoute(ccUDR);
} 

In this dialog, the APL code for handling input data is written. In the example, the incoming data is analyzed and depending on the first character in the incoming data, the receiving real-time collection workflow is chosen by setting the  LoadId  in the ConsumeCycleUDR, which is sent to the  Workflow_Bridge_FWD  agent. Adapt the code according to your requirements.

Workflow_Bridge_FWD

Workflow_Bridge_FWD is the Workflow Bridge real-time forwarding agent that sends data to the Workflow Bridge real-time collection agent. Double-click on Workflow_Bridge_FWD to display the configuration dialog for the agent.

In this dialog, the following settings have been made:

  • The agent has been configured to use the profile that was defined in the section above, Define a Profile.

Result

The Result agent is an Analysis agent that receives the returning ConsumeCycleUDRs and potential ErrorCycleUDRs from the Workflow_Bridge_FWD agent. Double-click on the Analysis agent to display the configuration dialog.


Example - APL code

consume { 
    if (instanceOf(input, wfb.ErrorCycleUDR)) { 
        debug("Something went wrong"); 
    } else if (instanceOf(input, wfb.ConsumeCycleUDR)) { 
        wfb.ConsumeCycleUDR ccUDR = (wfb.ConsumeCycleUDR)input; 
        WFBridge.myFormat.myInternal data = 
       (WFBridge.myFormat.myInternal)ccUDR.Data; 
       string msg = ("Value " + data.inputValue + 
       " was executed by " + data.executingWF);
       debug(msg); }
    }
 
}

In this dialog, the APL code for further handling of the UDRs is written. In the example, only simple debug messages are used as output. Adapt the code according to your requirements.

Create the Real-Time Collection Workflows

In this workflow, a Workflow Bridge real-time collection agent collects the data that has been sent in a ConsumeCycleUDR from the Workflow Bridge real-time forwarding agent and returns an updated ConsumeCycleUDR.

Workflow_Bridge_Coll

Workflow_Bridge_Coll is the Workflow Bridge real-time collection agent that receives the data that the Workflow Bridge real-time forwarding agent has sent over the bridge. Double-click on the Workflow_Bridge_Coll agent to display the configuration dialog for the agent.

In this dialog, the following settings have been made:

  • The agent has been configured to use the profile that was defined in the section above, Define a Profile.

  • The default port that the collector server will listen on for incoming requests has been set to default value "3299".

Analysis

The Analysis agent is the Analysis agent that receives and analyses the data originally sent from the Workflow Bridge real-time forwarding agent in the ConsumeCycleUDR, as well as the workflow state information delivered in the WorkflowStateUDR.

Double-click on the agent to display the configuration dialog.


Example - APL code

consume { 
    if (instanceOf(input, WorkflowStateUDR )) { 
         udrRoute((WorkflowStateUDR)input, "response"); 
    } else if (instanceOf(input, ConsumeCycleUDR)) { 
         wfb.ConsumeCycleUDR ccUDR = (wfb.ConsumeCycleUDR)input; 
         WFBridge.myFormat.myInternal data = 
        (WFBridge.myFormat.myInternal)ccUDR.Data; 
        debug("Incoming data: " + data.inputValue); 
        data.executingWF = 
        (string)mimGet("Workflow","Workflow Name"); 
        ccUDR.Data = data; 
        udrRoute(ccUDR, "response"); 
    } else { 
        debug(input); 
   } 
 }

In this example, each ConsumeCycleUDR will populate the data field  executingWF with the name of the executing workflow. Also WorkflowStateUDRs are routed back. Adapt the code according to your requirements.

Instance Table

Since this example will load balance between three workflows, additional workflows is added in the workflow table.

Right-click in the workflow template and choose Workflow Properties to display the Workflow Properties dialog.

In this dialog, the following settings have been made:

  • Workflow - Execution - Execution Settings and Workflow_Bridge_Coll - WFB_Collector - Port have default checked, which means they will use the configured value in the template unless a new value is given in the Workflow Table.

  • Workflow_Bridge_Coll - WEB_Collector - loadID has Per Workflow set, which means that the value must be specified in the Workflow Table.

The Workflow Table will contain three workflows, that all will communicate with the real-time forwarding workflow.

Populate the Workflow Table with the correct settings for each workflow:

  • Name should be set to a unique name for each workflow.
  • Set which EC each workflow will execute on in Execution Settings.
  • Each workflow needs to have a unique port assigned for communication with the Workflow_Bridge_FWD agent. In case workflows are configured to run on different ECs (configured on a different server), then the workflows can share the same ports.

  • The loadID need to correspond with the APL code and should be "1", "2" and "3" in this example

Load Balancing 

There are two types of load balancing strategies that can be used. Only one type may be active at a time. 

  • Static — This load balancing method allows for a specific number of LoadIDs to be defined in the workflow instances. 
  • Dynamic — The dynamic balancing method will automatically distribute the load.