使用nodeclery会创建太多的连接

2024-06-01 09:46:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用node-celery将消息发布到RabbitMQ实例(3.5.7),然后该实例将消息分发给几个python celery工作人员。一切似乎都很好,但是在多次测试之后,似乎套接字描述符被填满了,从而拒绝了更多的连接。我的猜测是连接应该关闭,但它们不是。 enter image description here

这是我的节点.js发送到相应路由的代码。我曾经尝试添加client.end,但它甚至不发送消息。在

// Initialize connection to rabbitmq
var client = celery.createClient({
    CELERY_BROKER_URL: config.rabbitmq.connection,
    CELERY_ROUTES: config.rabbitmq.routes,
    IGNORE_RESULT: true
});

//send the message to the worker
client.on('connect', function () {
    var calculateTotal = client.createTask("calculateTotal\.run");
    var emailUser = client.createTask("emailUser\.run");
    var subscribeToMailing = client.createTask("subscribeToMailing\.run");

    calculateTotal.call([messageToRabbit]);
    emailUser.call([messageToRabbit]);
    subscribeToMailing.call([messageToRabbit]);
});

Tags: to实例runclient消息varrabbitmqcall