Skip to content
This repository has been archived by the owner on Aug 6, 2020. It is now read-only.

SmartBear/JCeleryWorker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JCeleryWorker

A very simple Celery worker for Java.

Currently only supports RabbitMQ and JSON.

Usage

This replaces the worker from the First Steps with Celery tutoral:

public class DemoApp {
	public static void main(String[] _) throws Exception {
		JobService celeryService = new CeleryService();
      		celeryService.setInvokeHandler( new TaskHandler<InvokeJob>()
      		{
      			@Override
      			public void handle( InvokeJob t ) throws IOException
      			{
      				switch( t.getMethod() )
      				{
      					case "tasks.add":
      						t.complete( Job.Status.SUCCESS, add( t ) );
      				}
      			}
      		} );

      		celeryService.setRevokeHandler( new TaskHandler<InvokeJob>()
      		{
      			@Override
      			public void handle( InvokeJob t ) throws IOException
      			{
      				switch( t.getMethod() )
      				{
      					case "revoke":
      						t.complete( Job.Status.REVOKED );
      				}
      			}
      		} );

      		celeryService.startService();

		// ...
	}

	private static long add(CeleryTask t) {
		long x = (long) t.args.get(0);
		long y = (long) t.args.get(1);
		return x + y;
	}
}

About

A simple Java worker for Celery

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages