Class EventMessageUtils

java.lang.Object
io.axoniq.framework.workflow.runtime.util.EventMessageUtils

@Internal public class EventMessageUtils extends Object
Utility with factory methods for workflow event messages.
Since:
5.4.0
Author:
Simon Zambrovski, Stefan Dragisic
  • Method Details

    • workflowIdFilter

      public static Predicate<EventMessage> workflowIdFilter(String workflowId)
      Creates a filter predicate for event messages based on the workflow ID.
      Parameters:
      workflowId - ID of the workflow.
      Returns:
      predicate filtering event messages by workflow ID.
    • startedWorkflow

      public static EventMessage startedWorkflow(WorkflowEventPublicationContext workflowEventPublicationContext, String workflowName, VersionedType workflowDefinitionId, EventNameCustomizer customizer)
      Creates a new event message stating that a workflow has started.
      Parameters:
      workflowEventPublicationContext - read-only workflow event-publication context.
      workflowName - name of the workflow.
      customizer - event name customizer.
      Returns:
      event message.
    • completedWorkflow

      public static EventMessage completedWorkflow(WorkflowEventPublicationContext workflowEventPublicationContext, String workflowName, VersionedType workflowDefinitionId, EventNameCustomizer customizer)
      Creates a new event message stating that a workflow has completed successfully.
      Parameters:
      workflowEventPublicationContext - read-only workflow event-publication context.
      workflowName - name of the workflow.
      customizer - event name customizer.
      Returns:
      event message.
    • failedWorkflow

      public static EventMessage failedWorkflow(WorkflowEventPublicationContext workflowEventPublicationContext, String workflowName, Exception exception, VersionedType workflowDefinitionId, EventNameCustomizer customizer)
      Creates a new event message stating that a workflow has failed.
      Parameters:
      workflowEventPublicationContext - read-only workflow event-publication context
      workflowName - name of the workflow
      exception - exception that caused the failure
      workflowDefinitionId - workflow definition identity
      customizer - event name customizer
      Returns:
      event message.
    • timeoutWorkflow

      public static EventMessage timeoutWorkflow(WorkflowEventPublicationContext workflowEventPublicationContext, String workflowName, Instant time, VersionedType workflowDefinitionId, EventNameCustomizer customizer)
      Creates a new event message stating that a workflow has timed out.
      Parameters:
      workflowEventPublicationContext - read-only workflow event-publication context
      workflowName - name of the workflow
      time - time when the timeout occurred
      workflowDefinitionId - workflow definition identity
      customizer - event name customizer
      Returns:
      event message.
    • cancelledWorkflow

      public static EventMessage cancelledWorkflow(WorkflowEventPublicationContext workflowEventPublicationContext, String workflowName, VersionedType workflowDefinitionId, EventNameCustomizer customizer)
      Creates a new event message stating that a workflow has been cancelled.
      Parameters:
      workflowEventPublicationContext - read-only workflow event-publication context
      workflowName - name of the workflow
      workflowDefinitionId - workflow definition identity
      customizer - event name customizer
      Returns:
      event message.
    • cancelledWorkflow

      public static EventMessage cancelledWorkflow(WorkflowEventPublicationContext workflowEventPublicationContext, String workflowName, @Nullable Throwable cause, VersionedType workflowDefinitionId, EventNameCustomizer customizer)
    • startedStep

      public static EventMessage startedStep(WorkflowEventPublicationContext workflowEventPublicationContext, String stepName, Map<String,@Nullable Object> local, EventNameCustomizer customizer)
      Creates a new event message stating that a workflow step has started.
      Parameters:
      workflowEventPublicationContext - read-only workflow event-publication context.
      stepName - name of the step.
      local - local payload for the step.
      customizer - event name customizer.
      Returns:
      event message.
    • startedWaitForEventStep

      public static EventMessage startedWaitForEventStep(WorkflowEventPublicationContext workflowEventPublicationContext, String stepName, Map<String,@Nullable Object> local, EventNameCustomizer customizer)
      Creates a new started event for a wait-for-event step.
      Parameters:
      workflowEventPublicationContext - read-only workflow event-publication context
      stepName - name of the step
      local - local data
      customizer - customizer for event name
    • completedStep

      public static EventMessage completedStep(WorkflowEventPublicationContext workflowEventPublicationContext, String stepName, Map<String,@Nullable Object> result, @Nullable String resultPayloadReducerName, EventNameCustomizer customizer)
      Creates a new event message stating that a workflow step has completed.
      Parameters:
      workflowEventPublicationContext - read-only workflow event-publication context.
      stepName - name of the step.
      result - result of the step.
      resultPayloadReducerName - name of the result payload reducer, or null if no reducer is used, see LocalOnlyPayloadReducer, GlobalOnlyPayloadReducer, CombineGlobalAndLocalPayloadReducer
      customizer - event name customizer.
      Returns:
      event message.
    • completedWaitForEventStep

      public static EventMessage completedWaitForEventStep(WorkflowEventPublicationContext workflowEventPublicationContext, String stepName, Map<String,@Nullable Object> result, @Nullable String resultPayloadReducerName, EventNameCustomizer customizer)
      Creates a completed event for a wait-for-event step.
    • failStep

      public static EventMessage failStep(WorkflowEventPublicationContext workflowEventPublicationContext, String stepName, Throwable exception, EventNameCustomizer customizer)
      Creates a new event message stating that a workflow step has failed.
      Parameters:
      workflowEventPublicationContext - read-only workflow event-publication context.
      stepName - name of the step.
      exception - exception that caused the step failure.
      customizer - event name customizer.
      Returns:
      event message.
    • cancelledStep

      public static EventMessage cancelledStep(WorkflowEventPublicationContext workflowEventPublicationContext, String stepName, EventNameCustomizer customizer)
      Creates a new event message stating that a workflow step has been cancelled.
      Parameters:
      workflowEventPublicationContext - read-only workflow event-publication context.
      stepName - name of the step.
      customizer - event name customizer.
      Returns:
      event message.
    • cancelledStep

      public static EventMessage cancelledStep(WorkflowEventPublicationContext workflowEventPublicationContext, String stepName, @Nullable Throwable cause, EventNameCustomizer customizer)
      Creates a new event message stating that a workflow step has been cancelled, optionally with a cause.
      Parameters:
      workflowEventPublicationContext - read-only workflow event-publication context.
      stepName - name of the step.
      cause - the cause of the cancellation, or null.
      customizer - event name customizer.
      Returns:
      event message.
    • cancelledWaitForEventStep

      public static EventMessage cancelledWaitForEventStep(WorkflowEventPublicationContext workflowEventPublicationContext, String stepName, @Nullable Throwable cause, EventNameCustomizer customizer)
      Creates a cancelled event for a wait-for-event step.
    • retryingStep

      public static EventMessage retryingStep(WorkflowEventPublicationContext workflowEventPublicationContext, String stepName, StepRetryInfo retryInfo, EventNameCustomizer customizer)
      Creates a new event message stating that a workflow step is retrying.
      Parameters:
      workflowEventPublicationContext - read-only workflow event-publication context.
      stepName - name of the step.
      retryInfo - retry information payload.
      customizer - event name customizer.
      Returns:
      event message.
    • retryStartedStep

      public static EventMessage retryStartedStep(WorkflowEventPublicationContext workflowEventPublicationContext, String stepName, StepRetryInfo retryInfo, EventNameCustomizer customizer)
      Creates a new event message stating that a retry attempt of a workflow step has started.
      Parameters:
      workflowEventPublicationContext - read-only workflow event-publication context
      stepName - the name of the retry started step
      retryInfo - retry information payload, attempt is the attempt being started
      customizer - event name customizer
      Returns:
      the retry started event message
    • timeoutStep

      public static EventMessage timeoutStep(WorkflowEventPublicationContext workflowEventPublicationContext, String stepName, Instant time, EventNameCustomizer customizer)
      Creates a new event message stating that a workflow step has timed out.
      Parameters:
      workflowEventPublicationContext - read-only workflow event-publication context.
      stepName - name of the step.
      time - time when the timeout occurred.
      customizer - event name customizer.
      Returns:
      event message.
    • timeoutWaitForEventStep

      public static EventMessage timeoutWaitForEventStep(WorkflowEventPublicationContext workflowEventPublicationContext, String stepName, Instant time, EventNameCustomizer customizer)
      Creates a timed-out event for a wait-for-event step.
    • versionMigrationStep

      public static EventMessage versionMigrationStep(WorkflowEventPublicationContext workflowEventPublicationContext, String changeId, String version, EventNameCustomizer customizer)
      Creates a new event message recording a migration step for the given changeId. The wire-level event name comes from EventNameCustomizer.versionMigrationEventName(String, Map) — by default <changeId>.Versioned (e.g. Payment-redesign.Versioned). The MessageType.version() on the resulting event reflects the workflow's new version. The event is published as a StepStatus.COMPLETED step event with versionChangeId + version migration metadata keys; the versionChangeId presence identifies it as a migration step.
      Parameters:
      workflowEventPublicationContext - read-only workflow event-publication context.
      changeId - developer-chosen identifier of the code change.
      version - the new workflow version being recorded.
      customizer - event name customizer.
      Returns:
      event message.