---
id: ADR-ACC-BKS-011
title: Shared dispatch and run history for recurring work
product_area: accounting
module: books
revision: 1
status: proposed
design_intent: proposed
source_sha:
  services-accounting: f47cb263875bbc0c5640fba7dae6785ec32695f8
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
decision: >-
  Recurring Accounting work uses schedule rows owned by business records. A
  minute dispatcher claims due occurrences and publishes run messages to one
  queue; a consumer invokes registered handlers. Billing preparation is still
  among those handlers.
constrains:
  - SVC-ACC-BKS-maintenance
  - WF-ACC-BKS-008
  - STATE-ACC-BKS-004
  - DOM-ACC-BKS-006
origin: >-
  Shared schedules library and Accounting's schedules record (as cited in code);
  FND-ACC-BKS-023; services-accounting
  docs/architecture/accounting-2.0/02-decisions.md#C-7
alternatives:
  - option: Create a cloud schedule for every business record.
    why_not: >-
      This proposed alternative adds per-record infrastructure instead of timing
      saved with the owner’s database transaction.
  - option: Implement a scheduler in each owning module.
    why_not: 'That would duplicate claiming, retries, pause handling and run history.'
consequences:
  - Owner changes and schedule changes can commit together.
  - >-
    A unique run does not prevent repeated unfinished handler execution. Invalid
    definitions and five consecutive failures pause future scheduling without an
    examined attention notice.
  - >-
    Moving Billing timing out of Accounting requires replacing the existing
    preparation work registration.
supersedes: []
evidence:
  - >-
    services-accounting at f47cb263:
    modules/maintenance/aws/scheduling.module.ts
  - >-
    services-accounting at f47cb263:
    modules/maintenance/services/scheduled-work/accounting-scheduled-work.ts
---

# Shared dispatch and run history for recurring work

## Context

Several modules need recurrence, execution history and failure handling. Accounting uses one shared schedule mechanism and registers each owning module’s work handler.

## Decision

Recurring Accounting work uses schedule rows owned by business records. A minute dispatcher claims due occurrences and publishes run messages to one queue; a consumer invokes registered handlers. Billing preparation is still among those handlers.

## Alternatives Considered

Create a cloud schedule for every business record. This proposed alternative adds per-record infrastructure instead of timing saved with the owner’s database transaction.

Implement a scheduler in each owning module. That would duplicate claiming, retries, pause handling and run history.

## Consequences

Owner changes and schedule changes can commit together.

A unique run does not prevent repeated unfinished handler execution. Invalid definitions and five consecutive failures pause future scheduling without an examined attention notice.

Moving Billing timing out of Accounting requires replacing the existing preparation work registration.
