How xxl-job/xxl-job-admin works
Project Type and Purpose
• XXL-JOB is a full-stack distributed task scheduling platform:
• “xxl-job-admin” – the scheduling center (backend + web UI).
• “xxl-job-core” – the shared library that implements the scheduling protocol, executor registration, job dispatching, callback, and utility classes.
• “xxl-job-executor-samples” – example executor applications (frameless, Spring-Boot) that show how business code plugs into the core.
• Users access the Admin web UI to CRUD jobs; the Admin persists data to a relational database; executors register themselves and receive dispatch commands via REST; job results and logs flow back asynchronously.
Main Components
• Web Client (browser)
• Admin Service (Spring Boot + Spring MVC + MyBatis + Freemarker)
• Web Layer (controllers, interceptor, resolver)
• Core Scheduler Engine (XxlJobScheduler, Cron, Trigger Pool, Thread Pools)
• Route/Registry/Alarm Modules
• Service Layer / DAO Layer (MyBatis mappers → RDBMS)
• RDBMS (MySQL/PostgreSQL)
• Executors (one or many instances)
• XxlJobExecutor (core client)
• JobHandler implementations (Java, scripts via GLUE, CLI)
• Registry thread, callback thread, log file cleaner
• External Services
• Email/SMS/3rd-party alarm
• Docker/Kubernetes (container images provided)
Relationships and Data Flows
• Users → HTTP → Admin Service (UI) → JDBC → RDBMS
• Admin Scheduler Engine polls job table → computes triggers → pushes HTTP REST calls to Executors
• Executors periodically heart-beat & register → HTTP REST → Admin
• Executors execute business handlers → log files → callback REST → Admin → save logs to RDBMS
• On failure/timeouts → Admin invokes Alarm module → external email/SMS
• GLUE tasks: Admin serves code fragments; executors fetch and compile at runtime.
Architectural Patterns & Design Principles
• Center-oriented scheduling (single Admin with HA clustering via DB locks)
• Executor registration & discovery (pull registry list from DB)
• Fully asynchronous flows (scheduling, execution, callback)
• Pluggable routing strategies (round-robin, fail-over, broadcast, consistent-hash)
• Thread-pool isolation for slow vs. fast tasks
• MVC for Web UI; layering (Controller → Service → DAO).
• Cross-language via RESTful API; dynamic job code via GLUE.
Technologies & Frameworks
• Spring Boot, Spring MVC
• MyBatis + MyBatis-Mapper XML
• Freemarker templates + static assets (AdminLTE, jQuery, CronGen, CodeMirror)
• Maven multi-module project
• Java concurrency utilities
• Dockerfile for containerization
• RESTful APIs for Admin ↔ Executor
Step-by-Step Diagramming
• MVC Web Layer
• Scheduler Core
• Registry & Routing
• Alarm Module
• Service/DAO
3. “Admin Service” → “RDBMS” (MySQL)
• Inside executor: “Registry Thread”, “Callback Thread”, “JobExecutor”
5. Connector from Executor → Admin (“heartbeat/registry”)
6. Connector from Executor → Admin (“execute callback & logs”)
7. Connector Admin → External Alarm Service (“email/SMS”)
8. GLUE code flow: Admin → Executor fetch → compile → run.
Summary