https://github.com/juforg/celery-spring-boot-starter
Springboot starter for celery using celery-java, which is Java implementation of Celery client and worker.
https://github.com/juforg/celery-spring-boot-starter
asynctask celery celery-java java java-python springboot-starter
Last synced: about 1 month ago
JSON representation
Springboot starter for celery using celery-java, which is Java implementation of Celery client and worker.
- Host: GitHub
- URL: https://github.com/juforg/celery-spring-boot-starter
- Owner: juforg
- License: mit
- Created: 2021-08-27T09:11:40.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-06-26T01:53:45.000Z (over 1 year ago)
- Last Synced: 2025-07-24T23:46:20.609Z (7 months ago)
- Topics: asynctask, celery, celery-java, java, java-python, springboot-starter
- Language: Java
- Homepage:
- Size: 32.2 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# celery-spring-boot-starter
Springboot starter for celery using celery-java,
which is Java implementation of [Celery](https://docs.celeryproject.org/en/v5.1.2/) client and worker. Quoting from the project website:
> Celery is an asynchronous task queue/job queue based on distributed message passing. It is focused on real-time operation, but supports scheduling as well.
> The execution units, called tasks, are executed concurrently on a single or more worker servers using multiprocessing, Eventlet, or gevent. Tasks can execute asynchronously (in the background) or synchronously (wait until ready).
> Celery is used in production systems to process millions of tasks a day.
For more info, [celery-java](https://github.com/juforg/celery-java)
The aim is to be compatible with existing [Python Celery implementation][celery]. That means you should be able
to run a Java client with a Python worker or vice-versa. Tested with Python Celery 5.1.
## Maven dependency
Releases are available from Maven Central. Latest version: [](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22vip.appcity%22%20AND%20a%3A%celery-spring-boot-starter%22)
```xml
vip.appcity
celery-spring-boot-starter
...
```
Snapshots are available from [Sonatype OSRH](https://s01.oss.sonatype.org//content/groups/public):
```xml
sonatype
https://oss.sonatype.org/content/groups/public
true
always
```
## init config in application.yml
```yaml
celery:
queue: "demo:celery"
broker: amqp://guest:guest@localhost:5672/vhost
# backend:
```
## Calling Python task from Java
1. Start a celery worker as described in [First Steps with Celery][celery-py-start].
2. define a worker task with python
```Python
@celery.task(name='test.dummy_task')
def dummy_task(num):
print(num)
return "finished"
```
3. Call the task by name in java
```java
@Resource
private Celery celery;
celery.submit("test.dummy_task", new Object[]{1});
```
## enable multi queue
1. init config in application.yml
```yaml
celery:
enabled: true
enableMultiQueue: true
queue: "demo:celery"
broker: amqp://guest:guest@localhost:5672/vhost
# backend:
taskQueueMaps:
"test.dummy_task": "celery"
"test.dummy_task2": "celery"
"test.dummy_task3": "celery1"
"test.dummy_task4": "celery2"
```
3. Call the task by name in java
```java
@Resource
private CeleryTaskDistributor celeryTaskDistributor;
celeryTaskDistributor.submit("test.dummy_task", new Object[]{1});
```
## Relase notes
* 1.0 - Initial release. enable to call Python task from Java without result.
* 1.1 - add support for multi queue
[celery-py-start]: http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html
[celery]: http://www.celeryproject.org/