Skip to content
Grails Jesque Plugin
Groovy Java
Pull request Compare This branch is 72 commits behind michaelcameron:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Grails Jesque

Jesque is an implementation of Resque in Java. It is fully-interoperable with the Ruby and Node.js (Coffee-Resque) implementations.

The grails jesque plugin uses jesque and the grails redis plugin as a dependency. While it uses jesque for the core functionality it makes it groovier to use in grails.

There is also a grails jesque-web plugin initially ported from the jesque-web spring-mvc app, which itself was based on the Sinatra web app resque-web in resque. Either UI will allow you to see what's in your queues and view and re-process failed messages.

A scheduler (a la Quartz) has been added to support scheduled injection of jobs. The syntax is very similar to the grails Quartz plugin.

How do I use it?

Add the jesque plugin to grails, it will automatically pull in jesque with it's dependencies, and the grails redis plugin.

grails install-plugin jesque

You must also have redis installed in your environment.

Example to enqueue

class BackgroundJob {
    def someOtherService //auto-wiring supported

    def perform( arg1, arg2 ) {
        def domainObject = DomainClass.get(arg1) //GORM supported
        domainObject.message = arg2

class SomeOtherClass {
    def jesqueService

    def doWorkAsync() {
        jesqueService.enqueue( 'myQueueName', BackgroundJob.simpleName, 1, 'hi there')

Workers can be started manually by calling

    jesqueService.startWorker( 'myQueueName', BackgroundJob.simpleName, BackgroundJob )

or automatically upon start-up with the following config

grails {
    jesque {
        workers {
            someNameForYourWorkerPool {
                workers = 3 //defaults to 1
                queueNames = 'myQueueName' //or a list
                jobTypes = [(BackgroundJob.simpleName):BackgroundJob]

The redis pool used is configured in the redis plugin:

grails {
    redis {
        host = localhost //default
        prot = 6379 //default


Jobs should be placed in grails-app/jobs similar to the Quartz plugin. However, to not clash with quartz, and to retain similarties with resque, the method to execute must be called perform.

You can run the script create-jesque-job to create a shell of a job for you automatically. The following will create a BackgroundJob in the grails-app/jobs folder.

grails create-jesque-job package.Background
class MyJob {
    static queue = 'MyJesqueQueue'
    static workerPool = 'MyWorkerPook'

    def injectedService //auto-wired

    static triggers = {
        cron name: 'MyJob', cronExpression: '0 0 23 * * ? *'

    def perform() { "Executing Job"


Unit and integration tests will also automatically be created. If you have spock installed and listed in your it will create an integration specification instead of a grails integration test.


  • Ability to execute methods on services without creating a job object
  • Wrap above ability automatically with annotation and dynamically creating a method with the same name + "Async" suffix
  • Create grails/groovy docs (gdoc?) to extensively document options
  • Support job/config changes when running as `grails run-app

Release Notes

  • 0.2.0 - released 2011-10-17
    • First publicly announced version
  • 0.3.0 - released 2011-02-03
    • First implementation of scheduler
  • 0.4.0-SNAPSHOT - release 2012-5-20
    • Gracefully shutdown threads
    • Handle changes to scheduled jobs during development


Copyright 2011 Michael Cameron

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Something went wrong with that request. Please try again.