Workflow run modes in EzyMarketing
Back to ezymarketingWorkflow run modes in EzyMarketing are designed around a simple idea: a
workflow run does not only define “which workflow to run”, but also “how that workflow should be scheduled”. The starting point is MarketingWorkflowRunType, which currently defines three core modes:ONE_TIME LOOP CONTINUATION
Overall architecture
A workflow run in EzyMarketing is associated with:
- the workflow to execute,
- the campaign participant segment,
- the run type,
- a cron expression,
- status,
-
nextRunTime, -
runCount, - the segment page token, which records how far the previous execution has processed.
A background executor continuously scans for
ACTIVATED workflow runs whose nextRunTime is due. It then fetches participants in batches, executes workflow steps, and updates either the run status or the next scheduled execution time.
flowchart TD
A[Background executor] --> B[Find due ACTIVATED workflow runs]
B --> C[Load workflow, campaign segment, and participant segment]
C --> D[Fetch participants using page token]
D --> E[Save/enroll participants]
E --> F[Run workflow steps]
F --> G[Update segment page token and run count]
G --> H{Participant round finished?}
H -- No --> B
H -- Yes --> I[Update workflow run]
I --> J{Run type}
J -- ONE_TIME --> K[Complete]
J -- LOOP / CONTINUATION / other type --> L[Calculate nextRunTime using cron]
L --> M{Beyond campaign end time?}
M -- Yes --> K
M -- No --> B
ONE_TIME
ONE_TIME means the workflow run is executed once.After the executor finishes one participant round, the workflow run is marked as
COMPLETED. Even if the record has a cronExpression, the runtime update path does not use cron to schedule another execution for ONE_TIME.This mode is suitable for campaigns that should run once at a specific time, such as sending an announcement email, syncing a fixed customer set, or activating a workflow for a specific segment.
sequenceDiagram
participant Ex as Executor
participant Run as Workflow Run
participant Seg as Participant Segment
participant Step as Workflow Steps
Ex->>Run: Load due ONE_TIME run
Ex->>Seg: Fetch participants by batch
Ex->>Step: Run steps for participants
Ex->>Run: Increase runCount and update lastRunTime
Ex->>Run: Set status = COMPLETED
LOOP
LOOP means the workflow run repeats based on cron.The key difference is how the campaign participant segment page token is handled. During each execution, the system fetches participants from the previously saved position. Once it reaches the end of the participant set,
LOOP increases runCount and resets the page token to 0, allowing the next round to start again from the beginning of the segment.In other words,
LOOP is useful when a workflow needs to repeatedly process the full participant segment on a schedule.
flowchart TD
A[Due LOOP run] --> B[Fetch participants after current page token]
B --> C{End of segment reached?}
C -- No --> D[Save new page token]
D --> A
C -- Yes --> E[Increase runCount]
E --> F[Reset page token to 0]
F --> G[Calculate nextRunTime by cron]
G --> A
CONTINUATION
CONTINUATION also runs on a cron schedule, but it handles the page token differently from LOOP.When a participant round finishes,
CONTINUATION does not reset the page token to 0. It keeps the last processed position so that the next run continues from there and only picks up newly added participants. If no participants are fetched, the campaign participant segment update may be skipped to avoid unnecessary changes to the page token or run count.This mode is suitable for continuous workflows where each scheduled execution should process only newly available data instead of scanning the entire segment again.
flowchart TD
A[Due CONTINUATION run] --> B[Fetch participants after current page token]
B --> C{New participants found?}
C -- No --> D[Skip segment update]
C -- Yes --> E[Run workflow for new participants]
E --> F[Update page token to last participant]
F --> G{Current round finished?}
G -- Yes --> H[Increase runCount and calculate nextRunTime]
G -- No --> A
D --> I[Calculate next scheduled run]
Cron and configuration UI
In the admin UI,
ONE_TIME, LOOP, and CONTINUATION all have a helper for generating cron expressions.For
ONE_TIME, the user selects a specific date and time. For LOOP and CONTINUATION, the UI treats both as recurring modes, so the user can choose repeat patterns such as minutely, hourly, daily, weekly, monthly, or yearly.
flowchart LR
A[Select run type] --> B{Type}
B -- ONE_TIME --> C[Select one-time date and time]
B -- LOOP or CONTINUATION --> D[Select repeat cycle]
D --> E[Generate cron expression]
C --> E
E --> F[Save into workflow run]
Extensible run types
Although the core enum defines three values, the list of workflow run types is not completely closed. The manager collects run types from three sources:
- core values from
MarketingWorkflowRunType, - types already saved in workflow run records,
- additional types from configuration.
This allows the system to display and preserve extended run types. However, in the current executor behavior, only
ONE_TIME, LOOP, and CONTINUATION have explicit runtime semantics. Other types, if present, are not treated as ONE_TIME, do not reset the page token like LOOP, and do not use the “skip segment update when no participants are found” behavior of CONTINUATION.
Conclusion
In EzyMarketing,
MarketingWorkflowRunType is more than a display label. It determines the lifecycle of a workflow run:-
ONE_TIME: runs once and then completes. -
LOOP: repeats and scans the segment again from the beginning after each full round. -
CONTINUATION: repeats but continues from the previous position, making it suitable for processing newly added data.
This design keeps “what the workflow does” separate from “how the workflow is triggered over time”, allowing the same workflow to support multiple operational strategies.