How t3573393/jdjjob works
Project type and purpose
• This is an open-source Java library (a port of Shopify’s delayed_job) that lets Java applications enqueue and process long-running tasks asynchronously.
• It provides an API for producers to enqueue “jobs” (plain Java objects), persists them in a MySQL table, and runs worker processes that poll the table, deserialize the job objects, execute them, and record success or failure.
File structure
• Top-level:
• pom.xml – Maven build, declares dependencies (MySQL JDBC driver, commons-dbutils, c3p0, Jackson).
• jobs.sql – DDL for the jobs table.
• Source layout (jdjjob/src/main/java/org/fartpig/jdjjob):
• DJJob & DJWorker – core enqueue/poll APIs.
• DJJobDao & DBUtils – DAO layer using commons-dbutils.
• Jackson integration for serializing job handlers into the handler column.
• DJRetryException, DJException – retry/failure control.
• Resources:
• c3p0-config.xml – database connection pool config.
• logback.xml – logging configuration.
• Tests mirror main packages, verifying DAO, serialization, utilities.
Key insights from the README
• System uses a single jobs table in MySQL to store job metadata and serialized handlers.
• Jackson is used for JSON serialization, c3p0 for connection pooling, commons-dbutils for DAO operations.
• Producer calls DJJob.enqueue(job, queueName); worker is new DJWorker(opts).start().