You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| `taskName(String)` | Explicitly names the task, making it a **singleton** with **upsert** semantics (see [Named Tasks](#named-singleton-tasks)) | Event name (for scheduled tasks) |
436
+
| `as(String)` | Explicitly names the task, making it a **singleton** with **upsert** semantics (see [Named Tasks](#named-singleton-tasks)) | Event name (for scheduled tasks) |
437
437
| `after(Duration)` | Initial delay before first execution | `Duration.ZERO` |
438
438
| `every(Duration)` | Delay between recurring executions (after each successful run) | None (single execution) |
439
439
| `cron(String)` | Spring Cron Expression for recurring execution | None |
All scheduled tasks (using any `Schedule` other than `Schedule.NOW`) are **singletons**. The task name determines the outbox message ID, ensuring only one active instance per name exists at any time.
451
451
452
-
- If an explicit `taskName` is set via `.taskName(...)`, it is used as the task name.
453
-
- If no explicit `taskName` is set, the **event name** is used as the task name.
452
+
- If an explicit name is set via `.as(...)`, it is used as the task name.
453
+
- If no explicit name is set, the **event name** is used as the task name.
454
454
455
455
Re-submitting a task with the same name **replaces** the existing entry entirely — the schedule, message content, and execution timestamp are all updated to reflect the latest submission. This follows **last-write-wins** semantics.
456
456
457
457
```java
458
458
// Only one "daily-cleanup" task will exist, regardless of how often this code runs
The upsert mechanism is safe for concurrent submissions. If a named task is re-submitted while it is currently being processed, the new submission is preserved and will be executed according to the updated schedule after the current execution completes.
483
483
484
484
::: warning
485
-
If you need multiple independent tasks for the same event (e.g., per-user reminders), you **must** set an explicit `taskName` to distinguish them. Without it, all submissions for the same event share one task name and re-submissions replace the existing task.
485
+
If you need multiple independent tasks for the same event (e.g., per-user reminders), you **must** set an explicit name via `.as(...)` to distinguish them. Without it, all submissions for the same event share one task name and re-submissions replace the existing task.
486
486
:::
487
487
488
488
@@ -493,14 +493,14 @@ Named tasks can be cancelled:
0 commit comments