久久久久久久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)前星期幾的值)
主站蜘蛛池模板: 日韩精品一区二区三区四区 | av大片 | 青青久草 | 操操操av | 一区二区三区视频在线 | 国产色网 | 亚洲一区二区三区桃乃木香奈 | 黄免费观看视频 | 国产一区二区三区视频在线观看 | 国产精品一区在线观看 | 中文字幕国产精品 | 亚洲综合视频 | 色视频一区二区 | a在线观看 | 偷拍自拍第一页 | 国产在线精品一区二区三区 | 日韩精品一区二区不卡 | 暖暖日本在线视频 | 国产精品久久久久一区二区三区 | 久久免费观看视频 | 成人免费在线观看 | 成人高清在线视频 | av午夜激情| 久草免费在线视频 | 亚洲成人福利在线观看 | 日日干干 | 91视视频在线观看入口直接观看 | 久久电影一区 | 日韩一区中文字幕 | 夜夜夜夜夜夜曰天天天 | 欧美成年人 | 欧美综合网 | 国产成人免费视频 | 久久久久亚洲精品 | 一级片av| 亚洲a视频| 国产精品3区 | 国产国语精品 | 欧美久久一级特黄毛片 | xxx国产精品视频 | 久久99国产精品久久99果冻传媒 |