Class SubWorkflowCaller

java.lang.Object
com.scivicslab.pojoactor.workflow.SubWorkflowCaller
All Implemented Interfaces:
CallableByActionName

public class SubWorkflowCaller extends Object implements CallableByActionName
General-purpose sub-workflow caller actor.

This class provides a reusable pattern for calling sub-workflows from within a main workflow. It creates a new Interpreter instance, loads a YAML workflow definition, and executes it synchronously.

Usage Example:


 // 1. Create SubWorkflowCaller actor
 SubWorkflowCaller caller = new SubWorkflowCaller(system);
 IIActorRef<SubWorkflowCaller> ref = new IIActorRef<>("caller", caller, system);
 system.addIIActor(ref);

 // 2. In workflow YAML:
 matrix:
   - states: ["0", "1"]
     actions:
       - [caller, call, "sub-workflow.yaml"]
 

Action Methods:

  • call(yamlFilePath) - Calls the specified sub-workflow synchronously

Implementation Notes:

Lifecycle:

  1. Main workflow calls call action
  2. New Interpreter instance is created
  3. YAML file is loaded from /workflows/[yamlFilePath]
  4. Sub-workflow executes all steps until completion or error
  5. Interpreter goes out of scope and becomes eligible for GC
  6. Control returns to main workflow
Since:
2.5.0
Author:
devteam@scivics-lab.com
See Also:
  • Constructor Details

    • SubWorkflowCaller

      public SubWorkflowCaller(IIActorSystem system)
      Constructs a new SubWorkflowCaller.
      Parameters:
      system - the actor system to use for sub-workflow execution. This system is shared between main and sub-workflows.
  • Method Details

    • callByActionName

      public ActionResult callByActionName(String actionName, String args)
      Executes actions by name.

      Supported actions:

      • call - Calls a sub-workflow. The args parameter should contain the YAML filename (e.g., "my-workflow.yaml")
      Specified by:
      callByActionName in interface CallableByActionName
      Parameters:
      actionName - the name of the action to execute
      args - the arguments for the action (YAML filename for "call" action)
      Returns:
      ActionResult indicating success or failure
    • getCallCount

      public int getCallCount()
      Returns the number of successful sub-workflow calls.
      Returns:
      the call count