問題描述
我剛接觸 celery 和 java 2 天.:(
I just touch celery and java for 2 days. :(
現(xiàn)在,我有一個java客戶端通過rabbitmq發(fā)送任務(wù)的任務(wù).Celery 將是處理任務(wù)的工人.
Right now, I have a task that java client send task through rabbitmq. Celery will be the worker to handle task.
我知道 Python->rabbitmq->celery 很容易.但是我可以通過 java->rabbitmq->celery 做到這一點嗎?
I know it's easy for Python->rabbitmq->celery. But can I do this by java->rabbitmq->celery ?
草稿思路是把java函數(shù)用json序列化,然后用rabbitmq發(fā)送,再用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
謝謝
推薦答案
你當(dāng)然可以從 Java 中通過 RabbitMQ 發(fā)送消息.有一個用于與 RabbitMQ 交互的 Java 客戶端庫 - http://www.rabbitmq.com/api-guide.html
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
本頁描述了 Celery 消息格式 - http://docs.celeryproject.org/en/latest/internals/protocol.html.一種風(fēng)格使用 JSON,并且有很多現(xiàn)有的 Java 庫用于 JSON 讀寫;請參閱 http://json.org
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
你是對的.
上面鏈接的頁面包含代碼片段,RabbitMQ Java 庫有一些(小)示例.(至少,頁面上是這么說的.)
The page linked above includes code snippets, and the RabbitMQ Java library has some (small) examples. (At least, that's what the page says.)
這篇關(guān)于我可以通過rabbitmq使用java發(fā)送任務(wù)到芹菜嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!