Workflow Bridge Example Batch to Real-Time Scenario with Action UDR(3.0)

This section will show an example of a scenario where a batch forwarding workflow sends data to a real-time collection workflow. The batch workflow will deliver four UDRs to the real-time workflow and the second one will be returned with a user-defined Action UDR connected to it.

The following configurations will be created:

  • An Ultra format
  • A Workflow Bridge Profile
  • A Workflow Bridge Batch Forwarding Workflow
  • A Workflow Bridge Real-Time Collection Workflow Define an Ultra Format

A simple Ultra Format needs to be created both for the incoming UDRs as well as for the user-defined WfbActionUDR. 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 WFBActionUDR : 
   extends_class( "com.digitalroute.workflowbridge.transport.ultra.WfbActionUDR" ) {
  int type;
  ascii action;
};

external my_input sequential {
  // field definitions
  ascii myId : int(base10),terminated_by(",");
  ascii text : terminated_by(0xa);
};

// Decoder mapping
in_map inputMap :
    external( my_input ),
    target_internal( my_internal_TI ) {
    automatic;
};

decoder myDecoder : in_map( inputMap );
                
The input file used in this example should look like:
1,My first UDR
2,My second UDR
3,My third UDR
4,My forth UDR 

Define a Profile

The profile is used to connect the two workflows. See Workflow Bridge Profile for information how to open the Workflow Bridge Profile editor.

In this dialog, the following settings have been made:

  • Send reply Over Bridge  is not selected which means that only responses for WorkflowStateUDRs and UDRs with an Action UDR attached to the response will be returned to the forwarding workflow.

  • 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 forwarding workflow that is waiting for a WorkflowState UDR reply will timeout and abort (stop) after 60 seconds if no reply has been received from the collection workflow.

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

  • 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.

  • Number of Collectors  are set to 1 since only one collector since there will be a one-to-one connection in this example.

  • Set the UDR type to my_internal_TI by clicking on the  Add button. To remove a UDR type from the UDR Types list, select the UDR type click the Remove button.

Create a Batch Forwarding Workflow

In this workflow, a Disk agent collects data that is forwarded to an Analysis agent. The data is routed by the Decoder agent to the Workflow Bridge forwarding agent, which in turn forwards the data in a ConsumeCycleUDR to a Workflow Bridge real-time collection agent. Each time the Workflow Bridge batch forwarding workflow changes state, a WorkflowState UDR is sent to the Workflow Bridge real-time collection agent as well.

For more information regarding the states a workflow can have, see Workflow Monitor.

Since the  Send Reply over Bridge  option has not been configured, only ConsumeCycleUDRs with an Action UDR attached are returned from the Workflow Bridge real-time collection agent and routed to an Analysis agent in the batch forwarding workflow.

The workflow consists of a Disk collection agent named Disk, a Decoder agent named Decoder, a Workflow Bridge batch forwarding agent named Workflow_Bridge_FW and an Analysis agent named Actions.

Disk

Disk is a collection agent that collects data from an input file and forwards it to the Decoder agent.

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

In this dialog, the following settings have been made:

  • The agent is configured to collect data from the /home/trunk/in directory, which is stated in the  Directory  field. Enter the path to the directory where the file you want to collect is located.

  • The agent will collect all files in the directory.

Decoder

The Decoder agent receives the input data from the Disk agent, translates it into UDRs and forwards them to the Workflow_Bridge_FW agent. Double-click on the Decoder agent to display the configuration dialog.

In this dialog, choose the Decoder that you defined in your Ultra Format.

Workflow_Bridge_FW

Workflow_Bridge_FW is the Workflow Bridge batch forwarding agent that sends data to the Workflow Bridge real-time collection agent. Each incoming UDR will be included in the Data field of a  ConsumeCycleUDR  which is sent to the real-time workflow. Double-click on Workflow_Bridge_FW to display the configuration dialog for the agent.

In this dialog, the following setting has been made:

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

Analysis

The Analysis agent is an analysis agent that receives the responses from the Workflow_Bridge_FW agent. Since the profile does not have the  Send Reply Over Bridge option selected, the agent will only receive responses with an Action UDR. Double-click on the Analysis agent to display the configuration dialog.

In this dialog, the APL code for handling input data is written. In the example, there will be a debug printout of the UDRs with an Action UDR connected. Adapt the code according to your requirements

You can also see the UDR type used in the UDR Types field, in this example, it is a ConsumeCycleUDR.

Create a Real-Time Collection Workflow

In this workflow, a Workflow Bridge real-time collection agent collects the data that has been sent in a ConsumeCycleUDR from the Workflow Bridge batch forwarding agent. It also collects the WorkflowState UDRs that inform about state changes in the batch forwarding workflow.

An Analysis agent returns all ConsumeCycleUDRs to the Workflow Bridge real-time collection agent, to let the agent know when to send the DrainCycleUDR. The Analysis agent also replies to all WorkflowState UDRs, so that the Workflow Bridge batch forwarding agent will know when to move forward to the next Agent Execution State. For more information regarding the workflow execution states, see Workflow Monitor.

Workflow_Bridge_C

Workflow_Bridge_C is the Workflow Bridge Real-time Collection agent that receives the data that the Workflow Bridge Batch Forwarding agent has sent over the bridge. Double-click on the Workflow_Bridge_C 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 port that the collector server will listen on for incoming requests has been set to default value "3299". However, if the two workflows will execute on the same execution context, an ephemeral port is used instead.

Analysis

The Analysis agent is the Analysis agent that receives and analyses the data originally sent from the Workflow Bridge batch forwarding agent in the ConsumeCycleUDR, as well as the workflow state information delivered in the WorkflowState UDRs.

This agent will also look for the UDR that has its Id set to 2 and create an Action UDR for this.

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


Example - APL code

consume {
    if (instanceOf(input, wfb.WorkflowStateUDR)) { 
        udrRoute((wfb.WorkflowStateUDR) input); 
    } else if (instanceOf(input, wfb.ConsumeCycleUDR)) { 
        wfb.ConsumeCycleUDR ccUDR = (wfb.ConsumeCycleUDR) input; 
       //validate content of the incoming UDR 
       WFBridge.UltraFormat.my_internal_TI myUDR = 
       (WFBridge.UltraFormat.my_internal_TI) ccUDR.Data; 
       if (myUDR.myId == 2) { 
           //Create an action UDR 
           WFBridge.UltraFormat.WFBActionUDR myAction = 
           udrCreate( WFBridge.UltraFormat.WFBActionUDR); 
           myAction.type = 44; 
           myAction.action = "The second UDR will be returned to the WF";
           ccUDR.Action = myAction; 
       } 
       udrRoute((wfb.ConsumeCycleUDR) ccUDR); 
    } else { 
       debug(input); } 
    }
}


In this example, a reply is sent back to the Workflow_Bridge_C agent, by routing back the WorkflowStateUDR and ConsumeCycleUDRs. Adapt the code according to your requirements.

Note!

Since WorkflowState UDRs have to be routed back to the Workflow Bridge collection agent in order to be returned to the forwarding workflow, a "response" route have to be added from the Analysis agent to the Workflow Bridge collection agent.

You can see the UDR types used in the UDR Types field, i. e. WorkflowStateUDR and ConsumeCycleUDR.