Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ppzaq1's avatar

Events Listeners on multiple servers via Redis

Hello. I deploy my Laravel project on multiple servers, and my balancer distributes visitors between them.

I want to organize broadcast Events via Redis (queue) and listen to Events on all servers (servers have a common redis db).

I have Event class:

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class BaseRedisEvent implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public string $connection = 'redis';
    public string $queue = 'default';
    public string $channel = 'default';

    public function broadcastOn(): Channel
    {
        return new Channel($this->channel);
    }
}

And class Listener

use App\Events\Bitcoin\Address\CreatedEvent;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;

class BaseRedisListener
{
    public function __construct()
    {
    }

    public function handle(BaseRedisEvent $event)
    {
        Log::debug('New Event in Redis ' . var_export($event, true));
    }
}

After sending the event, I want the listener to work on all servers.

BaseRedisEvent::dispatch();

An entry is added to the logs only for the server that sent the event. I want for all servers. Can you help me?

0 likes
1 reply
rafito's avatar

Did you find a solution for this?

Please or to participate in this conversation.