Storage

JobRunr supports both SQL and NoSQL databases

JobRunr stores the job details for each job using a StorageProvider and supports all major SQL databases and NoSQL databases.

Important: you will need to add the correct dependency (jdbc-driver) for each of the databases below.

SQL databases

By default, JobRunr will automatically create the necessary tables for your database. If however you do not want to give the JobRunr DataSource DDL rights, you can easily create the tables JobRunr uses yourself using one of the following methods:

Run the DatabaseCreator

The DatabaseCreator class allows you to create the necessary tables using a terminal. You must provide a user which has DDL rights.

java -cp jobrunr-${jobrunr.version}.jar org.jobrunr.storage.sql.common.DatabaseCreator {jdbcUrl} {userName} {password}

If the command succeeds, a confirmation message will be shown.

Apply the SQL scripts yourself

  • Oracle - apply all the sql scripts found here.
  • Postgres - apply all the sql scripts found here.
  • MySql - apply all the sql scripts found here overriding some of these sql scripts with the MySql specific scripts found here.
  • MariaDB - apply all the sql scripts found here overriding some of these sql scripts with the MariaDB specific scripts found here.
  • DB2 - apply all the sql scripts found here.

Once you created the tables, you can configure JobRunr as follows (when using jobrunr-spring-boot-starter, this is not necessary):

JobRunr.configure()
    .useStorageProvider(new DefaultSqlStorageProvider(dataSource, DatabaseOptions.SKIP_CREATE))
    .useDefaultBackgroundJobServer()
    .initialize();

NoSQL databases

  • ElasticSearch - JobRunr will create the necessary indices to save all Jobs and Recurring Jobs automatically for you. They will be prefixed with jobrunr_
    • use the ElasticSearchStorageProvider together with a RestHighLevelClient
  • Mongo - JobRunr will create a database called jobrunr and all the necessary collection to save all Jobs and Recurring Jobs automatically for you
    • use the MongoDBStorageProvider - JobRunr supports all Mongo versions from Mongo 3.4 and up.
  • Amazon DocumentDB - JobRunr will create a database called jobrunr and all the necessary collection to save all Jobs and Recurring Jobs automatically for you
    • use the AmazonDocumentDBStorageProvider
  • Redis - JobRunr will create all necessary datatypes (Strings, Sets, Hashes, … ) automatically for you. You can choose out of two implementations:
    • either the JedisRedisStorageProvider which uses Jedis.
    • and the LettuceRedisStorageProvider which uses Lettuce. If you use this StorageProvider you also need to add a dependency to org.apache.commons:commons-dbcp2 as the Lettuce driver is not thread-safe when using Redis Transactions.
  • InMemory - JobRunr comes with an InMemoryStorageProvider, which is ideal for lightweight tasks that are server-instance specific and where persistence is not important. Note that if you use the InMemoryStorageProvider, you can not scale horizontally as the storage is not shared.
    • use the InMemoryStorageProvider for in-memory support