Interface ActionCallBuilder

All Known Subinterfaces:
MicroflowCallBuilder, UserActionCallBuilder

public interface ActionCallBuilder
Provides a builder for building an action call. This interface contains the common methods between user actions and microflows.
  • Method Details

    • execute

      <R> R execute(IContext context)
      Executes the action call synchronously.
      Type Parameters:
      R - result type of the action, which should match the return value of the action
      Parameters:
      context - the context in which the action should be executed
      Returns:
      the result of the action call
      Throws:
      IllegalArgumentException - if a retry is specified
    • executeInBackground

      void executeInBackground(IContext context, String queueName)
      Puts the action call on a task queue. It will be executed in a different thread, and potentially on a different cluster node. `inTransaction` option is ignored if microflows are called with this method. Execution will be performed in an equivalent context to the one that is provided as an argument:
      • if it is a context for a named user, then a new context for that user will be used
      • if it is a context for an anonymous user, then a new context for a new anonymous user with the same language/timezone will be used
      • if it is the system context, then the system context will be used

      Tasks are executed with an at-least once guarantee. This means that it is guaranteed that a task will get executed even if a cluster node crashes. In that case it may happen that the same task is re-executed on another cluster node.

      To execute a task on a the same cluster node as it is scheduled on, with an at-most once guarantee, please refer to the various `Core.schedule` methods.

      Parameters:
      context - the context that is used to schedule the background call. An equivalent context will be used for execution
      queueName - Name of a queue. It has to exist in the model
      Throws:
      MendixRuntimeException - if enqueueing the action call fails, for example if the queue doesn't exist
    • executeInBackground

      void executeInBackground(IContext context, String queueName, Date startAt)
      Puts the action call on a task queue. It will be executed in a different thread, and potentially on a different cluster node. `inTransaction` option is ignored if microflows are called with this method. Execution will be performed in an equivalent context to the one that is provided as an argument:
      • if it is a context for a named user, then a new context for that user will be used
      • if it is a context for an anonymous user, then a new context for a new anonymous user with the same language/timezone will be used
      • if it is the system context, then the system context will be used

      The action call will be executed after the given `startAt` date/time.

      Tasks are executed with an at-least once guarantee. This means that it is guaranteed that a task will get executed even if a cluster node crashes. In that case it may happen that the same task is re-executed on another cluster node.

      To execute a task on the same cluster node as it is scheduled on, with an at-most once guarantee, please refer to the `Core.schedule` methods.

      Parameters:
      context - the context that is used to schedule the background call. An equivalent context will be used for execution
      queueName - Name of a queue. It has to exist in the model
      startAt - The date/time after which the task should be executed
      Throws:
      MendixRuntimeException - if enqueueing the action call fails, for example if the queue doesn't exist
    • withRetry

      ActionCallBuilder withRetry(int numberOfAttempts, Duration interval)
      Performs the specified number of retries if the execution of the action fails with an exception. A fixed delay is used in between the retries. This setting only applies to actions that are executed as a background task.
      Parameters:
      numberOfAttempts - the maximum number of times to retry
      interval - the time to wait in between attempts
      Returns:
      the updated builder
    • withExponentialRetry

      ActionCallBuilder withExponentialRetry(int numberOfAttempts, Duration initialInterval)
      Performs the specified number of retries if the execution of the action fails with an exception. An exponentially increasing delay is used in between the retries. The interval doubles each time, up to a maximum of 1 day. This setting only applies to actions that are executed as a background task.
      Parameters:
      numberOfAttempts - the maximum number of times to retry
      initialInterval - the time to wait before the first retry
      Returns:
      the updated builder
    • withExponentialRetry

      ActionCallBuilder withExponentialRetry(int numberOfAttempts, Duration initialInterval, Duration maximumInterval)
      Performs the specified number of retries if the execution of the action fails with an exception. An exponentially increasing delay is used in between the retries. The interval doubles each time, up to the specified maximum. This setting only applies to actions that are executed as a background task.
      Parameters:
      numberOfAttempts - the maximum number of times to retry
      initialInterval - the time to wait before the first retry
      maximumInterval - the maximum time to wait in between attempts
      Returns:
      the updated builder