Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Added shutdown_hook_priority to rabbitmq_server #49

Open
wants to merge 1 commit into
base: develop
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
13 changes: 7 additions & 6 deletions includes/WpMinions/RabbitMQ/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] );
Expand All @@ -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.' );
}
Expand Down
10 changes: 6 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down