Coder Social home page Coder Social logo

elena-bondareva / bootique-jobs-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bootique-examples/bootique-job-examples

0.0 1.0 0.0 18 KB

An example of how to write jobs on Bootique platform

Home Page: http://bootique.io

License: Apache License 2.0

Java 100.00%

bootique-jobs-demo's Introduction

Build Status

bootique-jobs-demo

An example that explains how to write jobs on Bootique platform. Jobs can be run individually from command line, or scheduled with internal scheduler.

For additional help/questions about this example send a message to Bootique forum.

Prerequisites

  • Java 1.8 or newer.
  • Apache Maven.

Build the Demo

Here is how to build it:

git clone [email protected]:bootique-examples/bootique-jobs-demo.git
cd bootique-jobs-demo
mvn package

Run the Demo

Now you can check the options available in your app:

java -jar target/bootique-jobs-demo-1.0-SNAPSHOT.jar

Option                    Description
------                    -----------
--config <yaml_location>  Specifies YAML config location, which
                            can be a file path or a URL.
--exec                    Executes one or more jobs. Jobs are
                            specified with '--job' options
--help                    Prints this message.
--job <job_name>          Specifies the name of the job to run
                            with '--exec'. Available job names
                            can be viewed using '--list' command.
--list                    Lists all jobs available in the app
--schedule                Schedules and executes jobs according
                            to configuration. Waits indefinitely
                            on the foreground.

One of the options is --list that tells you what jobs are available:

java -jar target/bootique-jobs-demo-1.0-SNAPSHOT.jar --list

Available jobs:
     - simple
     - job1
     - injection
     - parameterized(d:date, l:long)

From here you have two options - run one or more jobs once from the command line, or start the app as a daemon and let the jobs run on a defined schedule. First option is great for testing/debugging or when you have an external scheduler (such as UNIX cron). So let's run both jobs at once:

java -jar target/bootique-jobs-demo-1.0-SNAPSHOT.jar --exec --job=simple --job=job1

Notice that the two jobs are executed in parallel. Some jobs support parameters, declaring them in metadata. Parameters can be configured in YAML configuration file under the "jobs" key (or via other Bootique configuration mechanisms, such as environment variables). Check params.yml and ParameterizedJob for an example. You can run this job as follows:

java -jar target/bootique-jobs-demo-1.0-SNAPSHOT.jar --exec --job=parameterized --config=params.yml

Now let's schedule jobs to run at a certain interval. Scheduling information is placed in a YAML file under the "scheduler" key. Check scheduler.yml for an example. It shows scheduling jobs with fixed delay, as well as using a cron expression. Run it and wait and see how jobs are invoked periodically (use Ctrl-C to stop the application):

java -jar target/bootique-jobs-demo-1.0-SNAPSHOT.jar --schedule --config=scheduler.yml

Clustering Jobs with Zookeeper

TODO

bootique-jobs-demo's People

Contributors

andrus avatar elena-bondareva avatar

Watchers

 avatar

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.