Skip to content

Expose a shared enum for lifecycle event kinds #1638

Closed

Description

@mathecruz

sdk-java currently models workflow/task lifecycle events as a set of concrete classes (WorkflowStartedEvent, TaskCompletedEvent, etc., in io.serverlessworkflow.impl.lifecycle) plus a separate class of CloudEvent-type string constants (LifecycleEvents). There's no single enum identifying "what kind of event is this" that consumers can switch/filter on without an instanceof chain or comparing against LifecycleEvents strings.

Downstream, at least two consumers in quarkiverse/quarkus-flow independently reimplement this same taxonomy as local enums:

  • opentelemetry/runtime: WorkflowEventType + TaskEventType, each pairing a constant with its LifecycleEvents id and a fromEvent(WorkflowEvent) classifier via instanceof checks.
  • testing (quarkus-flow-testing): EventType, a flat 16-value enum covering both workflow- and task-level events, used to classify recorded events in test assertions.

Both are hand-written mirrors of the same 16 event kinds sdk-java already defines via its event classes/LifecycleEvents constants.

Request: Expose a canonical enum (e.g. LifecycleEventType) in io.serverlessworkflow.impl.lifecycle, ideally with:

  • One value per concrete WorkflowEvent subtype (workflow- and task-level).
  • A way to classify an arbitrary WorkflowEvent instance to its LifecycleEventType (replacing the instanceof chains each consumer currently writes).
  • A link back to the matching LifecycleEvents CE-id constant, if practical.

This would let consumers (like Quarkus Flow's opentelemetry and testing modules) drop their local duplicates and depend on a single sdk-java-owned source of truth.

Activity

  1. self-assigned this
    on Aug 24, 2026
  2. fjtirado commented on Aug 31, 2026

    @fjtirado
    Collaborator

    @mcruzdev Please add the links to the qflow code, so I can recall the use case.

  3. mathecruz commented on Aug 31, 2026

    @mathecruz
    CollaboratorAuthor

    @mcruzdev Please add the links to the qflow code, so I can recall the use case.

    Here is the comment to a pull request where I am adding a new enum: quarkiverse/quarkus-flow#494 (comment).

    Additionally, @wmedvede added it to the openetelemetry module, see WorkflowEventType and TaskEventType.

  4. fjtirado commented on Aug 31, 2026

    @fjtirado
    Collaborator

    Hmmm, I have doubts about this one, I think the constant should suffice. If you check the open telemetry, the enum is used to print the constant.
    In any case, enum or constant, it seems useful to have a type() method in WorkflowEvent that return the enum/constant

  5. added 3 commits that reference this issue on Sep 1, 2026
    b7cb270
    f610aef
    c3877e2
  6. added a commit that references this issue on Sep 2, 2026
    edf79ec
  7. added theissue type on Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions