Backend Development 11 min read

PowerJob: A Comprehensive Introduction and Practical Guide to the New Generation Java Distributed Task Scheduling Framework

This article introduces PowerJob, explains its key features such as lock‑free scheduling, multiple execution modes, and workflow support, and provides step‑by‑step instructions for installing via Docker or JAR, configuring databases, setting up server and client projects, and creating and managing scheduled tasks in Java.

Java Architect Essentials
Java Architect Essentials
Java Architect Essentials
PowerJob: A Comprehensive Introduction and Practical Guide to the New Generation Java Distributed Task Scheduling Framework

PowerJob is an open‑source, Java‑based, enterprise‑grade distributed task scheduling platform that offers a web UI for task management, lock‑free scheduling, rich execution modes (single, broadcast, Map, MapReduce), workflow support, and easy integration of various processors (Shell, Python, HTTP, SQL, etc.).

Key Features

Simple visual management via a front‑end web interface.

Supports CRON, fixed frequency, fixed delay, and API‑driven scheduling.

Execution modes: single machine, broadcast, Map, MapReduce.

Workflow (DAG) configuration with data passing between nodes.

Broad executor support: Spring Bean, built‑in/out‑of‑process Java classes, Shell, Python, HTTP, SQL.

Online log viewing for easier debugging.

Minimal dependencies – only a relational database (MySQL/PostgreSQL/Oracle/MS SQLServer) is required.

Lock‑free design enables high availability and horizontal scalability.

Failure retry and recovery mechanisms.

Installation

PowerJob can be installed either via Docker (refer to the official Docker‑compose guide) or by running the JAR files.

To run from source:

CREATE DATABASE IF NOT EXISTS `powerjob-daily` DEFAULT CHARSET utf8mb4;

Clone the repository and build the server:

git clone https://github.com/PowerJob/PowerJob
cd PowerJob/powerjob-server
mvn install   // install dependencies to local repo
mvn package   // package the server JAR

Configure the server by editing powerjob-server/powerjob-server-starter/application-daily.properties with your database connection and environment (daily, pre, product).

Start the server with:

java -jar powerjob-server-starter/target/powerjob-server-*.jar

After the server starts, access http://localhost:7700 to see the login page.

Client Setup

Create a Spring Boot project and add the PowerJob worker starter dependency:

<dependency>
    <groupId>tech.powerjob</groupId>
    <artifactId>powerjob-worker-spring-boot-starter</artifactId>
    <version>4.3.2</version>
</dependency>

Configure application.yml (or application.properties ) with the worker settings, for example:

powerjob:
  worker:
    enabled: true
    enable-test-mode: false
    port: 27777
    app-name: powerjob-agent-test
    server-address: 127.0.0.1:7700
    protocol: http
    max-result-length: 4096
    max-lightweight-task-num: 1024
    max-heavy-task-num: 64

Add @EnableScheduling to the main class and implement a task processor by creating a bean that implements BasicProcessor :

@Component
public class SimpleJobServer implements BasicProcessor {
    @Override
    public ProcessResult process(TaskContext taskContext) throws Exception {
        String jobParams = taskContext.getJobParams();
        System.out.println("参数: " + jobParams);
        System.out.println("定时任务执行");
        return new ProcessResult(true, "定时任务执行成功");
    }
}

Run the client; the server UI will display the registered executor instance.

Creating a Task

In the PowerJob web console, click “New Task”, select the task type (API, CRON, Fixed Frequency, Fixed Delay, Workflow, etc.), configure the execution mode (single, broadcast, Map, MapReduce), and specify the processor class name, e.g., com.example.powerjobdemo.job.SimpleJobServer . After saving, the task appears in the task list and can be triggered manually or according to the schedule.

Advanced Configuration

Scheduling strategies: HEALTH_FIRST (first healthy node) or RANDOM .

Lifecycle settings to limit the active period of a task.

Runtime parameters such as maximum instance count, thread concurrency, and execution timeout.

All detailed configuration options are documented in the official PowerJob documentation.

By following the steps above, you can quickly set up PowerJob, create distributed scheduled jobs, and monitor their execution through the built‑in UI.

Backenddistributed systemsJavatask schedulingSpringBootPowerJob
Java Architect Essentials
Written by

Java Architect Essentials

Committed to sharing quality articles and tutorials to help Java programmers progress from junior to mid-level to senior architect. We curate high-quality learning resources, interview questions, videos, and projects from across the internet to help you systematically improve your Java architecture skills. Follow and reply '1024' to get Java programming resources. Learn together, grow together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.