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

$persistent_messages parameter wasn't passed further to queue declaration #112

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion src/AMQPLibConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public function PostToExchange($connection, $details, $task, $params)

$ch->queue_bind(
$details['binding'], /* queue name - "celery" */
$details['exchange'] /* exchange name - "celery" */
$details['exchange'], /* exchange name - "celery" */
$details['binding'] /* routing key - "celery" */
);

$msg = new \PhpAmqpLib\Message\AMQPMessage(
Expand Down
35 changes: 19 additions & 16 deletions src/Celery.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,34 +53,37 @@
class Celery extends CeleryAbstract
{
/**
* @param string host
* @param string login
* @param string password
* @param string vhost AMQP vhost, may be left empty or NULL for non-AMQP backends like Redis
* @param string exchange AMQP exchange to use. For Redis it maps to queue key name. See CELERY_DEFAULT_EXCHANGE in Celery docs. (set to 'celery' when in doubt)
* @param string binding AMQP binding a.k.a. routing key. See CELERY_DEFAULT_ROUTING_KEY. (set to 'celery' when in doubt)
* @param int port
* @param string connector Which connector library to use. One of: 'pecl', 'php-amqplib', 'php-amqplib-ssl', 'redis'
* @param int result_expire Expire time for result queue, milliseconds (for AMQP exchanges only)
* @param array ssl_options Used only for 'php-amqplib-ssl' connections, an associative array with values as defined here: http://php.net/manual/en/context.ssl.php
* @param string $host
* @param string $login
* @param string $password
* @param string $vhost AMQP vhost, may be left empty or NULL for non-AMQP backends like Redis
* @param string $exchange AMQP exchange to use. For Redis it maps to queue key name. See CELERY_DEFAULT_EXCHANGE in Celery docs. (set to 'celery' when in doubt)
* @param string $binding AMQP binding a.k.a. routing key. See CELERY_DEFAULT_ROUTING_KEY. (set to 'celery' when in doubt)
* @param int $port
* @param string $connector Which connector library to use. One of: 'pecl', 'php-amqplib', 'php-amqplib-ssl', 'redis'
* @param bool $persistent_messages False = transient queue, True = persistent queue. Check "Using Transient Queues" in Celery docs (set to false when in doubt)
* @see {http://docs.celeryproject.org/en/latest/userguide/optimizing.html#using-transient-queues}
* @param int $result_expire Expire time for result queue, milliseconds (for AMQP exchanges only)
* @param array $ssl_options Used only for 'php-amqplib-ssl' connections, an associative array with values as defined here: http://php.net/manual/en/context.ssl.php
*/
public function __construct($host, $login, $password, $vhost, $exchange='celery', $binding='celery', $port=5672, $connector=false, $result_expire=0, $ssl_options=[])

public function __construct($host, $login, $password, $vhost, $exchange='celery', $binding='celery', $port=5672, $connector=null, $persistent_messages=false, $result_expire=0, $ssl_options=[])
{
$broker_connection = [
$backend_connection = $broker_connection = [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of defining the same array twice?

'host' => $host,
'login' => $login,
'password' => $password,
'vhost' => $vhost,
'exchange' => $exchange,
'binding' => $binding,
'port' => $port,
'connector' => $connector,
'connector' => $connector !== false ? $connector : null,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

false is no longer the default, so you can drop this ternary.

'persistent_messages' => $persistent_messages,
'result_expire' => $result_expire,
'ssl_options' => $ssl_options
];
$backend_connection = $broker_connection;

$items = $this->BuildConnection($broker_connection);
$items = $this->BuildConnection($backend_connection, true);
$this->BuildConnection($broker_connection);
$this->BuildConnection($backend_connection, true);
}
}
2 changes: 1 addition & 1 deletion src/CeleryAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function BuildConnection($connection_details, $is_backend = false)
$connection_details = $this->SetDefaultValues($connection_details);
$ssl = !empty($connection_details['ssl_options']);

if ($connection_details['connector'] === false) {
if (is_null($connection_details['connector'])) {
$connection_details['connector'] = AbstractAMQPConnector::GetBestInstalledExtensionName($ssl);
}
$amqp = AbstractAMQPConnector::GetConcrete($connection_details['connector']);
Expand Down