Giter Site home page Giter Site logo

chakra-coder / jesque-cli Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pierredavidbelanger/jesque-cli

0.0 1.0 0.0 164 KB

A CLI for Jesque, an implementation of Resque in Java

License: GNU Lesser General Public License v3.0

Java 100.00%

jesque-cli's Introduction

jesque-cli

A command-line interface for Jesque, an implementation of Resque in Java.

Usage

With the latest jesque-cli-with-dependencies.jar snapshot:

$ java -jar jesque-cli-with-dependencies.jar --help
Usage: <main class> [options] [command] [command options]
  Options:
    -h, --help
       Print this help and quit
       Default: false
  Commands:
    enqueue      Enqueue a job
      Usage: enqueue [options] queue job
        Options:
          -a, --arg, --argument
             The arguments of the job
             Default: []
          -ja, --json-args, --json-arguments
             The arguments of the job in JSON (must be a JSON array)
          -jv, --json-vars, --json-variables
             The variables of the job in JSON (must be a JSON object)
          -p, --priority
             Execute job ASAP
             Default: false
          -r, --redis-url
             The Redis connection URL
             Default: redis://localhost:6379
          -v, --var, --variable
             The variables of the job
             Syntax: -vkey=value
             Default: {}

    work      Start worker(s) to execute jobs
      Usage: work [options] queue ...
        Options:
          -cp, --classpath, --class-paths
             The class paths to load job classes from
             Default: []
          -n, --num-workers
             The number of workers in the pool
             Default: 1
          -p, --packages
             The packages to look into for job classes
             Default: []
          -r, --redis-url
             The Redis connection URL
             Default: redis://localhost:6379

enqueue

To enqueue {"class":"TestAction","args":["a ctor arg"],"vars":{"prop":"a java bean property"}} into myqueue (with a running Redis at localhost:6379):

$ java -jar jesque-cli-with-dependencies.jar enqueue \
    myqueue TestAction \
    -a 'a ctor arg' \
    -v prop='a java bean property'

work

To run a worker that will run the above job from myqueue (with a running Redis at localhost:6379):

$ java -jar jesque-cli-with-dependencies.jar work \
    myqueue \
    -cp my-job.jar \
    -p com.acme.job

Where my-job.jar is a java jar package that contains the class TestAction into the com.acme.job package:

package com.acme.job;

import java.util.concurrent.Callable;

public class TestAction implements Callable<String> {
    private final String arg;
    private String prop;

    public TestAction(String arg) { this.arg = arg; }

    public void setProp(String prop) { this.prop = prop; }

    public String call() throws Exception {
        System.out.println(arg + " " + prop);
        return arg;
    }
}

Integration with Maven

Adding this plugin into the <project> <build> <plugins> element of a pom.xml will fetch the latest latest jesque-cli-with-dependencies.jar snapshot and copy it to target/dependency/jesque-cli.jar.

<plugin>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
        <execution>
            <id>copy-dependency</id>
            <phase>package</phase>
            <goals>
                <goal>copy</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>ca.pjer</groupId>
                        <artifactId>jesque-cli</artifactId>
                        <version>0.1.0-SNAPSHOT</version>
                        <classifier>jar-with-dependencies</classifier>
                        <destFileName>jesque-cli.jar</destFileName>
                    </artifactItem>
                </artifactItems>
            </configuration>
        </execution>
    </executions>
</plugin>

It will now be in a suitable place to be run with (for example) a Procfile:

web: java -jar target/my-app.jar
worker: java -jar target/dependency/jesque-cli.jar work myqueue -r $REDIS_URL -cp target/my-app.jar -p com.acme.job -n 2

jesque-cli's People

Contributors

pierredavidbelanger 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.