久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

從 Java 與 Django/Celery 互操作

Interoperating with Django/Celery From Java(從 Java 與 Django/Celery 互操作)
本文介紹了從 Java 與 Django/Celery 互操作的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時(shí)送ChatGPT賬號(hào)..

我們公司有一個(gè)基于 Python 的網(wǎng)站和一些基于 Python 的工作節(jié)點(diǎn),它們通過 Django/Celery 和 RabbitMQ 進(jìn)行通信.我有一個(gè)基于 Java 的應(yīng)用程序,它需要向基于 Celery 的工作人員提交任務(wù).我可以很好地從 Java 向 RabbitMQ 發(fā)送工作,但是基于 Celery 的工作人員永遠(yuǎn)不會(huì)接受工作.通過查看兩種類型的作業(yè)提交的數(shù)據(jù)包捕獲,存在差異,但我無法理解如何解釋它們,因?yàn)槠渲泻芏嗍嵌M(jìn)制文件,我找不到有關(guān)解碼的文檔.這里有沒有人有 Java/RabbitMQ 和 Celery 一起工作的參考或經(jīng)驗(yàn)?

Our company has a Python based web site and some Python based worker nodes which communicate via Django/Celery and RabbitMQ. I have a Java based application which needs to submit tasks to the Celery based workers. I can send jobs to RabbitMQ from Java just fine, but the Celery based workers are never picking up the jobs. From looking at the packet captures of both types of job submissions, there are differences, but I cannot fathom how to account for them because a lot of it is binary that I cannot find documentation about decoding. Does anyone here have any reference or experience with having Java/RabbitMQ and Celery working together?

推薦答案

我找到了解決方案.RabbitMQ 的 Java 庫是指交換/隊(duì)列/路由鍵.在 Celery 中,隊(duì)列名稱實(shí)際上是映射到 Java 庫中引用的交換.默認(rèn)情況下,Celery 的隊(duì)列只是celery".如果您的 Django 設(shè)置使用以下語法定義了一個(gè)名為myqueue"的隊(duì)列:

I found the solution. The Java library for RabbitMQ refers to exchanges/queues/routekeys. In Celery, the queue name is actually mapping to the exchange referred to in the Java library. By default, the queue for Celery is simply "celery". If your Django settings define a queue called "myqueue" using the following syntax:

CELERY_ROUTES = {
    'mypackage.myclass.runworker'      : {'queue':'myqueue'},
}

那么基于 Java 的代碼需要做如下的事情:

Then the Java based code needs to do something like the following:

        ConnectionFactory factory = new ConnectionFactory();
        Connection connection = null ;
        try {
            connection = factory.newConnection(mqHost, mqPort);
        } catch (IOException ioe) {
            log.error("Unable to create new MQ connection from factory.", ioe) ;
        }

        Channel channel = null ;
        try {
            channel = connection.createChannel();
        } catch (IOException ioe) {
            log.error("Unable to create new channel for MQ connection.", ioe) ;
        }

        try {
            channel.queueDeclare("celery", false, false, false, true, null);
        } catch (IOException ioe) {
            log.error("Unable to declare queue for MQ channel.", ioe) ;
        }

        try {
            channel.exchangeDeclare("myqueue", "direct") ;
        } catch (IOException ioe) {
            log.error("Unable to declare exchange for MQ channel.", ioe) ;
        }

        try {
            channel.queueBind("celery", "myqueue", "myqueue") ;
        } catch (IOException ioe) {
            log.error("Unable to bind queue for channel.", ioe) ;
        }

            // Generate the message body as a string here.

        try {
            channel.basicPublish(mqExchange, mqRouteKey, 
                new AMQP.BasicProperties("application/json", "ASCII", null, null, null, null, null, null, null, null, null, "guest", null, null),
                messageBody.getBytes("ASCII"));
        } catch (IOException ioe) {
            log.error("IOException encountered while trying to publish task via MQ.", ioe) ;
        }

事實(shí)證明,這只是術(shù)語上的差異.

It turns out that it is just a difference in terminology.

這篇關(guān)于從 Java 與 Django/Celery 互操作的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時(shí)間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉(zhuǎn)換為公歷?)
Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日歷到日期轉(zhuǎn)換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當(dāng)前星期幾的值)
主站蜘蛛池模板: 欧美黄色性生活视频 | 日日噜噜噜夜夜爽爽狠狠视频, | 国产精品视频一区二区三区四区国 | 久久国产传媒 | 99久久精品国产毛片 | 日韩网站免费观看 | 国内精品视频免费观看 | 欧美日韩在线看 | 伊人亚洲 | 精品一区在线看 | 91亚洲精华国产 | 天天操欧美 | 成人一区二区电影 | 久久久久久久久久久久久九 | 黄a免费网络 | 午夜影晥| 殴美黄色录像 | 亚洲国产精品一区二区第一页 | 狠狠色综合久久丁香婷婷 | 亚洲色片网站 | 久久亚洲欧美日韩精品专区 | 中文字幕一区二区三区乱码在线 | 久久区二区 | 精品福利在线 | 欧美中文一区 | 久久综合久久综合久久 | 欧美在线国产精品 | 一区二区伦理电影 | 91精品国产91久久久久久吃药 | 97色免费视频 | 91欧美精品成人综合在线观看 | 亚洲视频国产 | 成人av鲁丝片一区二区小说 | 999视频 | 日韩精品视频在线 | 亚洲成人在线免费 | av日韩一区| 福利一区在线观看 | 国产精品成人一区二区三区夜夜夜 | 国产成人一区二区三区电影 | 可以免费观看的av片 |