Listening for Messages

This page goes through all steps required to setup slave servers allowing Apex to run on multiple servers, meaning all event listeners will be handled by the other servers instead of the master server.


On all additional slave servers that will be accepting dispatched messages, you must have RabbitMQ installed and running. Plus within the /boot/container.php file on all servers running Apex you need to look for the line:

'BrokerInterface::class => Apex\Cluster\Brokers\Local::class,'

Change this line to something such as:

BrokerInterface::class => [Apex\Cluster\Brokers\RabbitMQ::class, [
    'host' =>',
        'port' => 5672,
    'user' => 'guest',
    'password' => 'guest'

Naturally, change the credentials as necessary. You may use a message broker other than RabbitMQ, but at the time of writing it would need to be integrated into Apex Cluster and support all methods within the BrokerInterface.

Install Apex Slave Installations

Install Apex on all remote servers. Install as normally, but add the --slave flag when initially running the apex script for the first time to enter the installation wizard:

apex --slave

Enter the redis connection information of the master server, and it will use the same SQL database as the master server.

Listen for Messages

For each slave server, you will need to ensure the following command is run during server startup:

apex listen

That's it. RabbitMQ will connect to the master server and begin listening for messages using the instance name the slave server was installed with.