Skip to content

OkraScheduler/OkraSpring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Okra

A simple and scalable Scheduler that uses MongoDB as backend.

codecov

Requirements

  • Java 8
  • MongoDB

Note

For now Okra only has one module which requires Spring Data MongoDB to work, but you can send a Pull Request any time creating a new maven module (like okra-spring) that requires only the raw MongoDB Driver.

Binaries

Gradle

build.gradle

    allprojects {
        repositories {
            ...
            maven { url "https://jitpack.io" }
        }
    }
    dependencies {
        compile 'com.github.OkraScheduler:OkraSpring:x.y.z'
    }

Maven

	<dependency>
	    <groupId>com.github.OkraScheduler</groupId>
	    <artifactId>OkraSpring</artifactId>
	    <version>x.y.z</version>
	</dependency>

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Quick start

Configure a scheduler

public class MyScheduler {
    
    private Okra okra;
    ...
    public void initScheduler() {
        okra = new OkraSpringBuilder<DefaultOkraItem>()
                        .withMongoTemplate(new MongoTemplate(client, "schedulerBenchmark"))
                        .withDatabase("schedulerBenchmark")
                        .withCollection("schedulerCollection")
                        .withExpiration(5, TimeUnit.MINUTES)
                        .withItemClass(DefaultOkraItem.class)
                        .build();        
    }
    ...    
}

Then, use this scheduler to retrieve scheduled items...

public class MyScheduler {
    
    private Okra okra;
    ...    
    public void retrieveLoop() {
        while (running) {
            Optional<DefaultOkraItem> scheduledOpt = okra.poll();
                if (scheduled.isPresent()) {
                    doSomeWork(scheduledOpt.get());                
                }    
        }
    }
    ...    
}

Build

To build:

$ git clone git@github.com:fernandonogueira/okra.git
$ cd okra
$ mvn install -DskipTests

Build Status

LICENSE

MIT License

Copyright (c) 2016 Fernando Nogueira

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.