Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Only connect to AMQP when posting task #51

Merged
merged 1 commit into from
Jul 21, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions celery.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class Celery
private $connection_details = array(); // array of strings required to connect
private $amqp = null; // AbstractAMQPConnector implementation

private $isConnected = false;

function __construct($host, $login, $password, $vhost, $exchange='celery', $binding='celery', $port=5672, $connector=false, $persistent_messages=false, $result_expire=0, $ssl_options = array() )
{
$ssl = !empty($ssl_options);
Expand Down Expand Up @@ -105,6 +107,12 @@ function PostTask($task, $args, $async_result=true,$routing_key="celery", $task_
{
throw new CeleryException("Args should be an array");
}

if (!$this->isConnected) {
$this->amqp->Connect($this->connection);
$this->isConnected = true;
}

$id = uniqid('php_', TRUE);

/* $args is numeric -> positional args */
Expand Down