Class RetryExecutor

java.lang.Object
ai.nervemind.app.executor.RetryExecutor
All Implemented Interfaces:
NodeExecutor

@Component public class RetryExecutor extends Object implements NodeExecutor
Executor for the "retry" node type - implements retry logic with configurable backoff strategies.

Provides automatic retry functionality for transient failures with sophisticated backoff algorithms. Ideal for unreliable external services, rate-limited APIs, or operations that may temporarily fail.

Node Parameters

Retry node configuration parameters
Parameter Type Default Description
operations List [] Operations to execute with retry protection
maxRetries Integer 3 Maximum retry attempts
backoffStrategy String "exponential" Backoff algorithm (see strategies below)
initialDelayMs Long 1000 Initial delay between retries
maxDelayMs Long 30000 Maximum delay cap
multiplier Double 2.0 Backoff multiplier
jitter Boolean true Add random jitter to delays
jitterFactor Double 0.1 Maximum jitter as fraction of delay
retryableErrors List [] Error types to retry (empty = all)
nonRetryableErrors List [] Error types to never retry

Backoff Strategies

  • fixed - Constant delay: initialDelayMs
  • linear - Linear increase: initialDelayMs * attempt
  • exponential - Exponential increase: initialDelayMs * multiplier^(attempt-1)
  • fibonacci - Fibonacci sequence: initialDelayMs * fib(attempt)

Output Data

Output keys added by this executor
Key Type Description
success Boolean True if operation eventually succeeded
attemptCount Integer Total attempts made (including initial)
totalDelayMs Long Total time spent waiting between retries
errors List Error messages from failed attempts
result Map Final operation result if successful

Jitter

When jitter=true, a random amount (0 to jitterFactor * delay) is added or subtracted from each delay to prevent thundering herd problems when multiple retry operations execute simultaneously.

See Also:
  • Constructor Details

    • RetryExecutor

      public RetryExecutor(@Lazy NodeExecutorRegistry nodeExecutorRegistry)
      Creates a new RetryExecutor with the given node executor registry.
      Parameters:
      nodeExecutorRegistry - the registry for accessing other node executors
  • Method Details

    • getNodeType

      public String getNodeType()
      Description copied from interface: NodeExecutor
      Unique identifier for the node type this executor handles. This must match the 'type' field in the JSON definition of the node.
      Specified by:
      getNodeType in interface NodeExecutor
      Returns:
      The unique type string (e.g., "httpRequest", "llmChat").
    • execute

      public Map<String,Object> execute(ai.nervemind.common.domain.Node node, Map<String,Object> input, ExecutionService.ExecutionContext context)
      Description copied from interface: NodeExecutor
      Executes the business logic for this node type.
      Specified by:
      execute in interface NodeExecutor
      Parameters:
      node - The node definition containing parameters and configuration. Use Node.parameters() to access user settings.
      input - Combined output from all upstream nodes that connected to this node. For simple flows, this contains the direct predecessor's output. For merge nodes, it contains combined data.
      context - Verification context providing access to workflow-scoped services, logger, and execution metadata.
      Returns:
      A Map containing the results of this node's execution. Keys in this map become available variables for downstream nodes.
      Note: Returning null is treated as an empty map.