What problem does it solve?
Synchronous API endpoints that run longer than 10 seconds get cut off by gateway timeouts (30s), causing 502/504 errors, duplicate user clicks triggering concurrent executions, unbounded in-memory state caches leaking memory, and lost tenant context in child threads.
Core Features & Use Cases
- Async State Machine Template: Provides a triggerAsync() + getStatus() pattern with IDLE/RUNNING/SUCCESS/FAILED states, tenant-isolated ConcurrentHashMap caching, and TTL-based eviction to prevent memory leaks.
- Concurrency & Context Safety: Prevents duplicate task triggering while RUNNING, restores TenantContext/SecurityContext/MDC in executor child threads, and defines frontend polling rules to avoid double useEffect timers.
- Use Case: A 6000-row product duplicate check that would exceed the 30s gateway timeout is converted into an immediately-returning trigger endpoint plus a status polling endpoint, with progress shown to all users and results surviving page refreshes.
Quick Start
Convert this slow synchronous endpoint into an async trigger plus status polling pattern following the async-task-pattern skill.