quartz-scheduler

0.1.4 • Public • Published

Quartz is a distributed scheduling engine. This API allows to use Quartz with node.js

Quartz does not expose HTTP services by himself. You'll need to build (maven) a war file from quartz-http.

    var Quartz = require('quartz-scheduler')

    var scheduler = new Quartz({
      queue: {
        redis: {
          port: 6379,
          host: 'localhost',
          auth: null,
          options: {
            // look for more redis options in [node_redis](https://github.com/mranney/node_redis)
          }
        }
      },
      listen: 8001, // the exposed HTTP api port
      callbackURL: 'http://localhost:8001/api/job', // the FQDN for the exposed service
      quartzURL: 'http://localhost:8080/scheduler/api', //the Quartz HTTP endpoint
      concurrency: 5, // max number of jobs to run in parallel (jobs are queued),
      monitor: false  // whether to expose a job processing monitoring interface
    })

    scheduler.on('jobName', function(jobId, data, done) {
      // jobId: the same jobId that was given upon scheduling
      // data ==> {foo: bar}
      // process the job here
      done(err) // optional error if processing the job went wrong
    })

    scheduler.schedule('jobName', new Date(), {foo: bar}, function(err, jobId) {

      // jobId is a string

      scheduler.cancel(jobId, function(err) {
        // err if something went wrong
      })
    })

Package Sidebar

Install

npm i quartz-scheduler

Weekly Downloads

28

Version

0.1.4

License

MIT

Last publish

Collaborators

  • nherment