From 0ee4c6efb0143dacbe74f4703876d1cfc336090b Mon Sep 17 00:00:00 2001 From: Stijn Janmaat Date: Wed, 19 Feb 2020 15:27:50 +0100 Subject: [PATCH] Added shutdown_hook_priority to rabbitmq_server --- includes/WpMinions/RabbitMQ/Connection.php | 13 +++++++------ readme.md | 10 ++++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/includes/WpMinions/RabbitMQ/Connection.php b/includes/WpMinions/RabbitMQ/Connection.php index 5e9cfb3..ea4a807 100644 --- a/includes/WpMinions/RabbitMQ/Connection.php +++ b/includes/WpMinions/RabbitMQ/Connection.php @@ -20,11 +20,12 @@ public function __construct() { } $rabbitmq_server = wp_parse_args( $rabbitmq_server, array( - 'host' => 'localhost', - 'port' => 5672, - 'username' => 'guest', - 'password' => 'guest', - 'vhost' => '/', + 'host' => 'localhost', + 'port' => 5672, + 'username' => 'guest', + 'password' => 'guest', + 'vhost' => '/', + 'shutdown_hook_priority' => 10, ) ); $this->connection = new \PhpAmqpLib\Connection\AMQPStreamConnection( $rabbitmq_server['host'], $rabbitmq_server['port'], $rabbitmq_server['username'], $rabbitmq_server['password'], $rabbitmq_server['vhost'] ); @@ -37,7 +38,7 @@ public function __construct() { $this->channel->queue_declare( 'wordpress', $rabbitmq_declare_passive_filter, $rabbitmq_declare_durable_filter, $rabbitmq_declare_exclusive_filter, $rabbitmq_declare_autodelete_filter ); - add_action( 'shutdown', array( $this, 'shutdown' ) ); + add_action( 'shutdown', array( $this, 'shutdown' ), $rabbitmq_server['shutdown_hook_priority'] ); } else { throw new \Exception( 'Could not create connection.' ); } diff --git a/readme.md b/readme.md index 46f2f3e..5f21682 100644 --- a/readme.md +++ b/readme.md @@ -167,10 +167,12 @@ $gearman_servers = array( # RabbitMQ config global $rabbitmq_server; $rabbitmq_server = array( - 'host' => '127.0.0.1', - 'port' => 5672, - 'username' => 'guest', - 'password' => 'guest', + 'host' => 'localhost', + 'port' => 5672, + 'username' => 'guest', + 'password' => 'guest', + 'vhost' => '/', + 'shutdown_hook_priority' => 10, ); Note: On RabbitMQ the guest/guest account is the default administrator account, RabbitMQ will only allow connections connections on that account from localhost. Connections to any non-loopback address will be denied. See the RabbitMQ manual on [user management](https://www.rabbitmq.com/rabbitmqctl.8.html#User_Management) and [Access Control](https://www.rabbitmq.com/rabbitmqctl.8.html#Access_Control) for information on adding users and allowing them access to RabbitMQ resources.