Class InMemoryWorkflowExecutionRepository

java.lang.Object
io.axoniq.framework.workflow.runtime.execution.InMemoryWorkflowExecutionRepository
All Implemented Interfaces:
WorkflowExecutionRepository, DescribableComponent

@Internal public class InMemoryWorkflowExecutionRepository extends Object implements WorkflowExecutionRepository
In-memory implementation of WorkflowExecutionRepository backed by a ConcurrentHashMap.
Since:
5.4.0
Author:
Stefan Dragisic
  • Constructor Details

    • InMemoryWorkflowExecutionRepository

      public InMemoryWorkflowExecutionRepository()
      Creates a new instance of .
  • Method Details

    • findById

      public Optional<WorkflowExecution> findById(String workflowId)
      Description copied from interface: WorkflowExecutionRepository
      Finds a workflow execution by its identifier.
      Specified by:
      findById in interface WorkflowExecutionRepository
      Parameters:
      workflowId - the workflow identifier
      Returns:
      an Optional containing the workflow execution, or empty if not found
    • findAll

      public Set<WorkflowExecution> findAll(Predicate<WorkflowExecution> predicate)
      Description copied from interface: WorkflowExecutionRepository
      Returns all stored workflow executions matching the given predicate, with at most one execution per workflow identifier.
      Specified by:
      findAll in interface WorkflowExecutionRepository
      Parameters:
      predicate - the predicate to match workflow executions against
      Returns:
      an unmodifiable collection of all workflow executions
    • findAll

      Description copied from interface: WorkflowExecutionRepository
      Returns all stored workflow executions whose state matches a query.
      Specified by:
      findAll in interface WorkflowExecutionRepository
      Parameters:
      query - state criteria to apply
      Returns:
      a future completing with an unmodifiable collection of matching workflow executions
    • save

      public WorkflowExecution save(String workflowId, Supplier<WorkflowExecution> factory)
      Description copied from interface: WorkflowExecutionRepository
      Atomically stores a new workflow execution if no execution exists for the given workflow identifier. If an execution already exists, returns the existing one without invoking the factory.
      Specified by:
      save in interface WorkflowExecutionRepository
      Parameters:
      factory - the factory to create a new workflow execution if absent
      Returns:
      the existing or newly created workflow execution
    • remove

      public WorkflowExecution remove(String workflowId)
      Description copied from interface: WorkflowExecutionRepository
      Removes the workflow execution associated with the given identifier.
      Specified by:
      remove in interface WorkflowExecutionRepository
      Parameters:
      workflowId - the identifier of the workflow to remove
      Returns:
      the removed WorkflowExecution, or null if no execution was found
    • removeAll

      public void removeAll(Predicate<WorkflowExecution> predicate)
      Description copied from interface: WorkflowExecutionRepository
      Removes all workflow executions matching the given predicate.
      Specified by:
      removeAll in interface WorkflowExecutionRepository
      Parameters:
      predicate - the predicate to match workflow executions against
    • clear

      public void clear()
      Description copied from interface: WorkflowExecutionRepository
      Removes all stored workflow executions.
      Specified by:
      clear in interface WorkflowExecutionRepository
    • describeTo

      public void describeTo(ComponentDescriptor descriptor)
      Description copied from interface: DescribableComponent
      Describe the properties of this DescribableComponent with the given descriptor.

      Components should call the appropriate describeProperty methods on the descriptor to register their properties. The descriptor is responsible for determining how these properties are formatted and structured in the final output.

      Best Practices: As a general rule, all relevant fields of a DescribableComponent implementation should be described in this method. However, developers have discretion to include only the fields that make sense in the context. Not every field may be meaningful for description purposes, especially internal implementation details. Furthermore, components might want to expose different information based on their current state. The final decision on what properties to include lies with the person implementing the describeTo method, who should focus on providing information that is useful for understanding the component's configuration and state.

      Example implementation:

       public void describeTo(ComponentDescriptor descriptor) {
           descriptor.describeProperty("name", this.name);
           descriptor.describeProperty("enabled", this.enabled);
           descriptor.describeProperty("configuration", this.configuration); // A nested component
           descriptor.describeProperty("handlers", this.eventHandlers);      // A collection
       }
       
      Specified by:
      describeTo in interface DescribableComponent
      Parameters:
      descriptor - The component descriptor to describe this DescribableComponentn its properties in.