
# All properties

`spring_boot_starter_scheduling` reads three properties: one switch, and two for the wait at shutdown. The schedules themselves are written in `@Scheduled`, whose text attributes can read any property of yours through `${...}` placeholders. The starter's metadata (`lib/spring_gen/spring_metadata.json`) lists the same 3 keys.

## Why

Scheduling should be off in most tests, and a server may need to let a nightly job finish before it stops. These are environment choices, so they are properties.

## Example

```yaml
# lib/resources/application.yml
spring:
  task:
    scheduling:
      enabled: true
      shutdown:
        await-termination: true
        await-termination-period: 30s

# Schedules of your own, read by @Scheduled(fixedRateString: r'${reports.rate:5m}').
reports:
  rate: 10m
  cleanup-cron: 0 0 3 * * *
```

The same in `.properties`:

```properties
# lib/resources/application.properties
spring.task.scheduling.enabled=true
spring.task.scheduling.shutdown.await-termination=true
spring.task.scheduling.shutdown.await-termination-period=30s
reports.rate=10m
reports.cleanup-cron=0 0 3 * * *
```

## The properties

| Key | Type | Default | Meaning |
|---|---|---|---|
| `spring.task.scheduling.enabled` | `bool` | `true` | `false` switches scheduling off: no `TaskScheduler` bean, no `@Scheduled` method runs (the `TaskExecutor` stays). Keeps tests predictable. |
| `spring.task.scheduling.isolates` | `primary` / `all` | `primary` | Which isolates run the `@Scheduled` methods when the web server has a pool of them (`server.isolates.count`): the application's first isolate only, so a job runs once, or every isolate. → [@Scheduled](scheduled.md#with-a-pool-of-isolates) |
| `spring.task.scheduling.shutdown.await-termination` | `bool` | `false` | `true`: closing the context with `closeAsync()` waits for the runs going on. A run, or its `Future`, is never interrupted. |
| `spring.task.scheduling.shutdown.await-termination-period` | `Duration` | none: no limit | The longest such wait (`30s`); then a warning naming the running tasks is logged and the shutdown goes on. |

- The synchronous `close()` cannot wait: a run going on finishes after the close (no further runs start), and `TimerTaskScheduler.runningTasks` lists it.
- A `TaskScheduler` bean of your own can wait the same way through a `destroy()` that returns a `Future` (`DisposableBean`).
- Durations: `500ms`, `30s`, `5m`, `PT30S`, or milliseconds. See [Durations](../spring-core-dart/conversion/durations.md).

## Not read

| Spring Boot key | Why |
|---|---|
| `spring.task.scheduling.pool.size` | Everything runs on Dart's event loop, without a thread pool. |
| `spring.task.scheduling.thread-name-prefix` | No threads. |
| `spring.task.execution.*` | The `TaskExecutor` has no pool to configure. `spring.task.execution.isolates.*` is read, by `spring_boot_dart`, for the `IsolateTaskExecutor`. |

## Read from other packages

| Key | Package | Meaning |
|---|---|---|
| `spring.flutter.lifecycle.pause-in-background` | `spring_boot_starter_flutter` | `true` by default: `@Scheduled` tasks stop while the app is in the background and start afresh when it comes back. |
| `server.isolates.count` | `spring_boot_starter_web` | Above one, the server runs a pool of isolates and `spring.task.scheduling.isolates` decides which of them schedule. |
| `spring.task.execution.isolates.*` | `spring_boot_dart` | The pool of the `IsolateTaskExecutor`, which runs work in other isolates. See [The task executor](../spring-core-dart/isolates/task-executor.md). |

## In Spring (Java)

`spring.task.scheduling.shutdown.await-termination` and `await-termination-period` are Spring Boot's; here they work with `closeAsync()` only. `spring.task.scheduling.enabled` is an addition (Spring switches scheduling with `@EnableScheduling`). `spring.task.scheduling.isolates` has no counterpart: a JVM's threads share one scheduler.

## See also

- [@Scheduled](scheduled.md)
- [Testing and time](testing.md)
