Giter Site home page Giter Site logo

fabioformosa / quartz-manager Goto Github PK

View Code? Open in Web Editor NEW
220.0 14.0 83.0 2.8 MB

REST API and UI Console Manager for Quartz Scheduler. This is a Java Library & UI embeddable single page app, to control and monitor jobs scheduled with Quartz Scheduler

License: Apache License 2.0

Java 61.93% CSS 0.10% JavaScript 0.63% HTML 6.86% TypeScript 28.94% SCSS 1.45% Shell 0.10%
quartz-scheduler scheduled-jobs quartz trigger daily-job scheduler-api scheduler-cron scheduler-library

quartz-manager's Introduction

Java CI with Maven npm CI Maven Central
Coverage Bugs Security Rating Maintainability Rating

Table Of Contents

QUARTZ MANAGER
    Quartz Manager UI
    Quartz Manager API
HOW IT WORKS
    Quartz Manager Starter API Lib
    Quartz Manager Starter UI Lib
    Quartz Manager Starter Security Lib
    Quartz Manager Persistence Lib
EXAMPLES
LIMITATIONS
ROADMAP
REPOSITORY
HOW TO CONTRIBUTE
SUPPORT THE PROJECT

QUARTZ MANAGER

In the last decade, the Quartz Scheduler has become the most adopted opensource job scheduling library for Java applications.

Quartz Manager enriches it with a REST API layer and a handy UI console to easily control and monitor a Quartz Scheduler.

Quartz Manager is a Java library you can import in your Spring-Based Web Application to run scheduled jobs, start&stop them and get the job outcomes. You can do it through HTTP calls to the the Quartz Manager API or in a visual manner through the Quartz Manager UI dashboard.

QUARTZ MANAGER UI

The Quartz Manager UI is a dashboard in the form of a single-page-application provided by the Quartz Manager Java library itself. You can have it embedded in your project, as well as you get embedded the Swagger UI.
It leverages the websockets to receive in real-time the trigger updates and the outcomes of the job executions.

QUARTZ MANAGER API

Quart-Manager exposes REST endpoints to interact with the Quartz Scheduler. This endpoints are invoked by Quartz Manager UI also. The REST API are documented by an OpenAPI Specification interface.

HOW IT WORKS

Quartz Manager can either coexist with your existing instance of Quartz or it can import itself the Quartz dependency.

In the first case, Quartz Manager is compatible with Quartz v2.3.x . Quartz Manager creates and configures its own instance of Quartz Scheduler and it manages only the jobs and the triggers created through it. Your other jobs and triggers, running in the existing quartz instance, are out of the scope of Quartz Manager.

In the latter case, in which there isn't an existing quartz instance, you can rely on Quartz Manager to speed up the setup of a Quartz instance, with a persistent storage also if you need it. Futhermore, if you start a bare project from scratch, just to run scheduled jobs, Quartz Manager comes with the option to enable a security layer to protect the API and the UI with an authentication model based on JWT.

FEATURES

  • You can schedule a Quartz Simple Trigger which allows you to start a job now or in a specific date-time, to set it as a recurring job with a certain time frequency, unlimited or limited on the number of fires and within a certain end date.
  • You can start, pause and resume the quartz scheduler via API or clicking the start/stop buttons at the UI console.
  • Leveraging on an active web-socket, the Quartz-Manager-UI updates in real time the progress bar and it displays the list of the latest logs produced by your quartz job.
  • You can enable a secure layer, if your project doesn't have any, to give access at the API and the UI only to authenticated users.
  • You can enable a persistent layer, to persist the config and the progress of your trigger, in a postgresql database.

GET STARTED

Requirements Java 9+, Spring Framework 5+ (Spring Boot 2.x)

Quart Manager is a modular library:

  • quartz-manager-starter-api (mandatory)
  • quartz-manager-starter-ui (optional)
  • quartz-manager-starter-security (optional)
  • quartz-manager-starter-persistence (optional)

In order to decrease the overall configuration time for the project, all modules of the library follow the approach of Spring Starters. Thus, it's enough to import the dependency to get started.

Below the list of the quartz-manager modules you can import.

Quartz Manager Starter API Lib

This is the only mandatory module of the library.
Add the dependency, make eligible for Quart Manager the job classes and set the props in your application.properties file.

Step 1. Dependency

Maven

<dependency>
  <groupId>it.fabioformosa.quartz-manager</groupId>
  <artifactId>quartz-manager-starter-api</artifactId>
  <version>4.0.9</version>
</dependency>

Gradle

implementation group: 'it.fabioformosa.quartz-manager', name: 'quartz-manager-starter-api', version: '4.0.9'

Step 2. Quartz Manager Job Classes

The job classes, which can be eligible for triggers managed by Quartz Manager, must extend the super-class AbstractLoggingJob. In this way, Quartz Manager is able to collect and display the outcomes at the UI console.

public class SampleJob extends AbstractLoggingJob {

   @Override
   public LogRecord doIt(JobExecutionContext jobExecutionContext) {
       ... do stuff ...
       return new LogRecord(LogType.INFO, "Hello from QuartManagerDemo!");
   }

}

Step 3. Quartz Manager API - App Props

Property Values Mandatory Default Description
quartz-manager.jobClassPackages string Yes java base package which contains your job classes
quartz-manager.oas.enabled boolean No false whether to create an OpenAPI instance to expose the OAS and the Swagger UI

REST API & OpenAPI Specification

Set the app prop quartz-manager.oas.enabled=true if you want to expose the OpenApi Specification of the Quartz Manager APIs.
Reach out the swagger-ui at the URL: http://localhost:8080/swagger-ui.html

If your project has already an OpenAPI instance and you've set quartz-manager.oas.enabled=true, then make sure to add an OpenApiGroup to group the API of your application. Quart Manager exposes its API in group called "Quartz Manager". If you use OAS Annotations:

  @Bean
  public GroupedOpenApi simplySpringDemoGroupedOpenApi() {
    return GroupedOpenApi.builder().group("myapp").packagesToScan("com.example.myapp").build();
  }

QUARTZ SETTINGS

Quartz Manager creates its own instance of a Quartz Scheduler.

By default, the managed quartz instance is instantiated with the following props:

org.quartz.scheduler.instanceName=quartz-manager-scheduler
org.quartz.threadPool.threadCount=1

You can customize the configuration of the Quartz managed by Quartz Manager creating a file managed-quartz.properties in the classpath (src/main/resources).
For further details about the quartz properties, click here.

Existing Quartz Instance

Quarz Manager imports transitively the Quartz Scheduler library ver 2.3.2. However, Quartz Manager can be imported even thought you've already imported the quartz scheduler lib. Indeed Quartz Manager coexists with the existing Quarz Scheduler Instance you've created in your project. In that case, Quartz Manager will manage the triggers created by it and it won't interfere with the other quartz instances. The prerequesite is that you've imported a quartz scheduler ver 2.3.x.

You can configure the Quartz instance managed by Quartz Manager through the file managed-quartz.properties and your own Quartz instance through the file quartz.properties.

If you've created a SchedulerFactoryBean, tag it as @Primary to avoid conflicts in-type, since Quartz Manager creates another bean of the same type.

    @Primary
    @Bean
    public SchedulerFactoryBean schedulerFactoryBean( JobFactory jobFactory, Properties quartzProperties) {
        SchedulerFactoryBean factory = new SchedulerFactoryBean();
        ...
        return factory;
    }

Quartz Manager Starter UI Lib

You can optionally import the following dependency to have the UI Dashboard to interact with the Quartz Manager API.

Dependency

Maven

<dependency>
  <groupId>it.fabioformosa.quartz-manager</groupId>
  <artifactId>quartz-manager-starter-ui</artifactId>
  <version>4.0.9</version>
</dependency>

Gradle

implementation group: 'it.fabioformosa.quartz-manager', name: 'quartz-manager-starter-ui', version: '4.0.9'

Reach out the UI Console at URL

if you run locally http://localhost:8080/quartz-manager-ui/index.html

Quartz Manager Starter Security Lib

Import this optional dependency, if you want to enable a security layer and allow the access to the REST API and UI only to authenticated users.
The authentication model of Quartz Manager is based on JWT.

If you're going to import Quartz Manager in a project with an existing configuration of Spring Security, consider the following:

  • Only if your existing security is cookie-based, actually you don't need to import the module quartz-manager-security-lib. Simply, Quartz Manager will be under the hat of your security setup. In all other cases (based on HTTP headers, query params, etc) Quartz Manager is not aware about your auth token and it will implement its own authentication model.
  • Quartz Manager Security relies on Spring Security upon a dedicated HTTP Spring Security Chain applied to the base path /quartz-manager. So it doesn't interfere with your existing security setup.
  • Quartz Manager Security keeps simple the authentication, adopting the InMemory Model. You have to define the users (in terms of username/credentials passed via application.properties) can access to Quartz Manager.
  • By default, the UI attaches the JWT Token to each request in the authorization header in the "Bearer" format.

Future development: the Quart Manager Security OAuth2 client.

Dependency

Maven

<dependency>
  <groupId>it.fabioformosa.quartz-manager</groupId>
  <artifactId>quartz-manager-starter-security</artifactId>
  <version>4.0.9</version>
</dependency>

Gradle

compile group: 'it.fabioformosa.quartz-manager', name: 'quartz-manager-starter-security', version: '4.0.9'

Quartz Manager Security Lib - App Props

Property Values Mandatory Default Description
quartz-manager.security.jwt.secret string Secret to sign the JWT Token
quartz-manager.security.jwt.expiration-in-sec number no 28800
quartz-manager.security.accounts.in-memory.enabled boolean no true
quartz-manager.security.accounts.in-memory.users[0].username string yes (if enabled)
quartz-manager.security.accounts.in-memory.users[0].password string yes
quartz-manager.security.accounts.in-memory.users[0].roles[0] string yes set the value ADMIN

Quart Manager Starter Persistence Lib

By default, Quartz Manager runs with a org.quartz.simpl.RAMJobStore that stores your managed scheduler in memory. The RAMJobStore is the simplest store and also the most performant. However it comes with the drawback that all scheduling data are lost if your applications ends or crashes. In case of a restarting of your app, you can't resume the scheduler from the point it stopped.
Import the Quartz Manager Persistence Module if you want to persist your scheduler data.
The pre-requesite is the availability of Postgresql database where Quartz Manager can store its information. You have to provide it a bare database and a postresql user granted for DDL and DML queries. About the DDL, consider that Quartz Manager Persistence will create all tables, it needs to work, at the bootstrap.

Dependency

Maven

<dependency>
  <groupId>it.fabioformosa.quartz-manager</groupId>
  <artifactId>quartz-manager-starter-persistence</artifactId>
  <version>4.0.9</version>
</dependency>

Gradle

compile group: 'it.fabioformosa.quartz-manager', name: 'quartz-manager-starter-persistence', version: '4.0.9'

Quartz Manager Persistence Lib - App Props

Property Values Mandatory Default Description
quartz-manager.persistence.quartz.datasource.url string yes eg. jdbc:postgresql://localhost:5432/quartzmanager
quartz-manager.persistence.quartz.datasource.user string yes
quartz-manager.persistence.quartz.datasource.password string yes

Examples

You can find some examples of different scenarios of projects which import Quartz Manager at the repository quartz-manager-use-cases

  • simply-spring - tipical scenario in which you create a minimal spring project from scratch dedicated to launch your scheduled jobs. Imported libraries: Quartz Manager API, Quartz Manager UI and Quartz Manager Security.
  • simply-spring-no-security - as simple-spring, without the security. Imported libraries: Quartz Manager API, Quartz Manager UI.
  • existing-security-cookie-based - It demonstrates how Quartz Manager stays under the security of your project, in case of an auth model based on cookies. Imported libraries: Quartz Manager API, Quartz Manager UI.
  • existing-security-header-based - It demonstrates how Quartz Manager Security can coexists with another Spring Security Config present in your project. Imported libraries: Quartz Manager API, Quartz Manager UI and Quartz Manager Security.
  • existing-quartz - It demonstrates how to Quartz Manager can coexist with a Quartz instance already present in your project Imported libraries: Quartz Manager API, Quartz Manager UI.
  • existing-quartz-and-storage - It demonstrates how to Quartz Manager Persistence can coexist with a Quartz instance already present in your project. Imported libraries: Quartz Manager API, Quartz Manager UI and Quartz Manager Persistence.
  • with-persistence - It demonstrates how to import the Quartz Manager Persistence and get created the quartz tables automatically at the bootstrap

Limitations

Step by step, day by day

Quartz Manager has a work-in-progress roadmap to be full-fledged library to manage a Quartz Scheduler.

At this stage of the roadmap, these are the limitations:

  • Currently you cannot start multiple triggers or multiple jobs. At the moment a workaround is to launch multiple projects based on Quartz Manager.
  • Currently you can only start Quartz Simple Trigger. The support to other kind of triggers will come soon: Calendar Interval Trigger, Cron Interval Trigger, Daily Interval Trigger
  • Currently the cluster mode is not supported
  • Currently the persistence of Quartz Manager supports only the PostgreSQL. The support to other king of triggers will come soon: MySQL, MariaDB, SqlServer, Oracle, H2.

ROADMAP

Take a look a the Project Roadmap.
Don't hesitate to give your feedback, your opinion is important to understand the priority.

Next steps in the roadmap are:

Repository

Checkout the master branch to get the sourcecode of the latest released versions.
Checkout the develop branch to take a look at the sourcecode of the incoming release.

HOW-TO CONTRIBUTE

For tech details, how-to run locally the project and how-to contribute, reach out this other README.md

❤️ SUPPORT THE PROJECT ❤️

Sometimes it's a matter of a kind action. You can support Quartz Manager and its continuous improvement turning on a github star on this project ⭐

quartz-manager's People

Contributors

fabiof-ddg avatar fabioformosa avatar midhunadarvin avatar vladimirshefer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

quartz-manager's Issues

Backend: quick refactoring

quartz-manager-security

  • WebSecurityConfigJWT: extract constant for the context path
  • WebSecurityConfigJWT: appName mustn't be configurable
  • WebSecurityConfigJWT: remove bean at userpwdFilterLoginConfigurer and formLoginConfigurer
  • JwtAuthenticationSuccessHandlerImpl: Set a JWT response strategy as default
  • InMemoryAccountProperties: add a security prefix to the prop quartz-manager.accounts.in-memory
  • WebSecurityConfigJWT: put a default value to quartz-manager.security.login-model.form-login-enabled and quartz-manager.security.login-model.userpwd-filter-enabled
  • spring.factory: import only a new config class which extends the basePackageScan
  • AjaxAuthenticationFilter: remove
  • Remove classes under the package model
  • Swagger exclusion: test
  • JwtSecurityProperties: "enabled" is unused

quartz-manager-persistence

  • PersistenceConfig: test if the source of quartzDatasourceUser quartzDatasourcePassword quartzDatasourceUrl is correct

quartz-manager-api

  • SchedulerConfig: set a ifMissing to the conditionalOnProperty
  • Api without sec
  • Set stateless when the auth strategy is not based on cookies
  • UserController: 404 in case of anon user
  • TriggerStatus vs TriggerFiredBundle
  • Name of the scheduler

Feature request

HI

thanks for the application working fine , anyway is there any possibility to add multiple jobs

Thanks

CI: set up an integrated test runner

The project needs a CI to run all tests I'm going to write, all times new changes are pushed.
Discover how this can be achieved using github or travis.

Backend: test coverage improving

quartz-manager-common

  • unit test: DateUtils
  • unit test: Try

quartz-manager-security

  • unit test: JwtAuthenticationSuccessHandlerImpl

quartz-manager-persistence

  • Add testcontainer, create an SpringBootApplicationTest and test if liquibase works and if the triggers are correctly stored and fetched

quartz-manager-api

  • WebsocketConfig: AbstractWebSocketMessageBrokerConfigurer is deprecated
  • SchedulerController: MockMVC tests
  • TriggerController: missing a mockMvc test
  • input validation

quartz-manager-ui takes me to login page without 'security layer'

  • I have only added 'quartz-manager-starter-api' and 'quartz-manager-starter-ui' as dependencies.
  • When I go to the quartz-manager-ui/index.html, it forwards me to the login page. Why?
  • No combination of username/password can get me past the login page (as near as I can tell). Why?

Note: This may be another issue for me to raise separately, but my app already has AutoWiringSpringBeanJobFactory,
scheduler, jobDetail, etc. in my existing @configuration (as well as existing Quartz jobs).
In order to integrate your API/.jars, I had to duplicate some of your SchedulerConfig beans
in my @configuration. I'm still a bit new to the Quartz API but I'm thinking most people will
have the same situation as me so you probably need to devise a way to "integrate" with
existing application context definitions.

Fully-fledged support for a single Simple Trigger

As a user,
I want to set up all types of triggers and all params for the trigger
So I can start trigger different than a simple trigger with a daily frequency and max num of occurences.

Complete support to set up all types of triggers and all params of a trigger.

Integration with consumer projects which already imported Quartz

I report the following quote from the issue #41 raised by @rwellman-ats:

my app already has AutoWiringSpringBeanJobFactory,
scheduler, jobDetail, etc. in my existing @configuration (as well as existing Quartz jobs).
In order to integrate your API/.jars, I had to duplicate some of your SchedulerConfig beans
in my @configuration. I'm still a bit new to the Quartz API but I'm thinking most people will
have the same situation as me so you probably need to devise a way to "integrate" with
existing application context definitions.

How to execute quartz-manager

Hi Fabio,
I chanced upon your quartz-manager repository and it resembles to something I have been looking for.
So I downloaded and ran mvn spring-boot:run and the application started successfully.

But I do not know where to go from there. What are the exact steps. Can you provide a small guide for me of the various endpoints you have and how to navigate through them.

http://localhost:8080/manager

doesnt work.

Thanks,
Anuj Kumar

Error Management

Errors returned by all http request must be supported.

  • Spinner for all fetching: scheduler, trigger list, trigger detail, progress data
  • Error actions: toast for POST (creation/update trigger)
  • Error actions: red icon for GET

TriggerType: SimpleTrigger

As a user,
I want to create a SimpleTrigger
So I can set all properties provided by a SimpleTrigger, not covered by the current trigger

This story is part of the epic #52

The UI will look for a simple trigger with a given name otherwise the user could create a simple trigger with the given name

cannot build with maven

daniel@maggie:/quartz-manager/quartz-manager-parent/quartz-manager-web$ mvn spring-boot:run
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] Scanning for projects...
[INFO]
[INFO] ---------< it.fabioformosa.quartz-manager:quartz-manager-web >----------
[INFO] Building Quartz Manager Web 2.2.2-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:2.3.4.RELEASE:run (default-cli) > test-compile @ quartz-manager-web >>>
[WARNING] The POM for it.fabioformosa.quartz-manager:quartz-manager-api:jar:2.2.2-SNAPSHOT is missing, no dependency information available
[WARNING] The POM for com.sun.xml.bind:jaxb-osgi:jar:2.2.10 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.126 s
[INFO] Finished at: 2020-10-16T16:29:44Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project quartz-manager-web: Could not resolve dependencies for project it.fabioformosa.quartz-manager:quartz-manager-web:war:2.2.2-SNAPSHOT: Could not find artifact it.fabioformosa.quartz-manager:quartz-manager-api:jar:2.2.2-SNAPSHOT -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
daniel@maggie:
/quartz-manager/quartz-manager-parent/quartz-manager-web$

Pluggability: make simpler to inject a custom job to be scheduled

According my opinion, the first step of growth is to improve the mechanics to customize/submit the job to be scheduled.
Currently, a developer must fork the project, add his job and build a deliverable. Too tricky!
The idea is to adopt a framework that supports pluggability. Quartz-Manager could be deployed once and the user should upload a jar with his job, likely developed with spring-boot.
I'm testing two libraries:

I've developed a PoC: https://github.com/fabioformosa/sbp-pluggable-project
I'm stuck plugging a jar in the form of executable spring boot jar. I've reported some feedbacks at this issue: hank-cp/sbp#10

Edit: Quick Reference

  • quartz-manager.accounts.in-memory: enabled + users (name, password, roles)
  • quartz-manager.security.jwt: enabled, secret, expirationInSec, cookieStrategy(enabled, cookie), headerStrategy(enabled,header)
  • quartz-manager.persistence.quartz.datasource (url, user, password)
  • quartz-manager.jobClassPackages

Layout Re-Design

  • HeaderBar for the Scheduler
  • SideBar for the Trigger List
  • Add Button for creating triggers
  • Main Layout: heights
  • Trigger Detail Card
  • Trigger List - Selection
  • Job Progress
  • Job Logs
  • animation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.