Class BulkWorkflow

    • Field Detail

      • VAR_CONCURRENCY

        public static final String VAR_CONCURRENCY
        State variable to define the maximum concurrency for executing child workflows.
        See Also:
        Constant Field Values
      • SPLIT_WORK

        public static final WorkflowState SPLIT_WORK
        Bulk workflow states.
      • WAIT_FOR_CHILDREN_TO_FINISH

        public static final WorkflowState WAIT_FOR_CHILDREN_TO_FINISH
    • Constructor Detail

      • BulkWorkflow

        protected BulkWorkflow​(String type)
        Extend bulk workflow definition.
        Parameters:
        type - The type of the workflow.
      • BulkWorkflow

        public BulkWorkflow()
        Create bulk workflow definition.
    • Method Detail

      • splitWorkImpl

        protected boolean splitWorkImpl​(StateExecution execution,
                                        com.fasterxml.jackson.databind.JsonNode data)
        Override this to create child workflows or add the children before starting the parent.
        Parameters:
        execution - State execution context.
        data - Child data.
        Returns:
        True to start processing the children, false to wait for children to be created.
        Throws:
        RuntimeException - Thrown by default implementation if children are not created before the parent is started.
      • waitForChildrenUntil

        protected org.joda.time.DateTime waitForChildrenUntil()
        Override this to customize the time to wait for new children before waking up. Default is one hour.
        Returns:
        Time when parent should wake up to check if new children have been added.
      • waitForChildrenToFinish

        public NextAction waitForChildrenToFinish​(StateExecution execution,
                                                  int concurrency)
        Check if all child workflows have finished. Start new children if needed and allowed by concurrency limit.
        Parameters:
        execution - State execution context.
        concurrency - The maximum number of child workflows to start.
        Returns:
        Action to retry this state at the time returned by waitForChildrenToCompleteUntil().
      • isRunning

        protected boolean isRunning​(WorkflowInstance instance)
        Override this to determine if the child workflow is running or not. The default implementation returns true if the instance state is finished or created.
        Parameters:
        instance - The child workflow instance to check.
        Returns:
        True if the child is running, false otherwise.
      • waitForChildrenToCompleteUntil

        protected org.joda.time.DateTime waitForChildrenToCompleteUntil()
        Override this to customize the time to wait for children to finish. Default is 15 minutes. This is a safety mechanism only, as when the children normally go to finished state, they will automatically wake up the parent workflow.
        Returns:
        The time when parent should wake up to check if the children are finished.