Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use java send task to celery through rabbitmq?

I just touch celery and java for 2 days. :(

Right now, I have a task that java client send task through rabbitmq. Celery will be the worker to handle task.

I know it's easy for Python->rabbitmq->celery. But can I do this by java->rabbitmq->celery ?

The draft idea is that serialization the java function by JSON and then send by rabbitmq, and then handle by celery.

It's better to have example code and could be run directly

thanks

like image 208
James Avatar asked Nov 21 '25 19:11

James


1 Answers

You can certainly send messages through RabbitMQ from Java. There is a Java client-side library for interfacing with RabbitMQ - http://www.rabbitmq.com/api-guide.html

This page describes the Celery message format - http://docs.celeryproject.org/en/latest/internals/protocol.html. One flavour uses JSON, and there are lots of existing Java libraries for reading and writing in JSON; see http://json.org

It's better to have example code and could be run directly

You are correct.

The page linked above includes code snippets, and the RabbitMQ Java library has some (small) examples. (At least, that's what the page says.)

like image 103
Stephen C Avatar answered Nov 24 '25 09:11

Stephen C



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!