問題描述
我剛接觸 celery 和 java 2 天.:(
I just touch celery and java for 2 days. :(
現在,我有一個java客戶端通過rabbitmq發送任務的任務.Celery 將是處理任務的工人.
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函數用json序列化,然后用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
謝謝
推薦答案
你當然可以從 Java 中通過 RabbitMQ 發送消息.有一個用于與 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.一種風格使用 JSON,并且有很多現有的 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.)
這篇關于我可以通過rabbitmq使用java發送任務到芹菜嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!