PHP code example of uzapoint / eventbus-core

1. Go to this page and download the library: Download uzapoint/eventbus-core library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

uzapoint / eventbus-core example snippets


// config/eventbus.php
return [

    'exchanges' => [
        'auth.events',
        'business.events',
    ],

    'queues' => [
        [
            'name' => 'auth_ms.business_events',
            'exchange' => 'business.events',
            'routing_keys' => [
                'tenant.registration.initiated',
            ],
        ],
    ],

    'handlers' => [
        'tenant.registration.initiated' => ProcessTenantCreation::class,
    ],

];

use Uzapoint\EventBus\RabbitMQService;

app(RabbitMQService::class)->publish(
    exchange: 'business.events',
    routingKey: 'tenant.registration.initiated',
    data: [
        'auth_user_id' => 12,
        'email' => '[email protected]',
    ],
    headers: ['idempotency_key' => $key], // optional: used as the event id
);

'idempotency' => [
    'enabled' => true,
    'ttl' => 3600,      // how long a successfully processed event is remembered
    'lock_ttl' => 120,  // processing lock, released if the handler fails
    'redis_prefix' => 'event:processed:',
],

'monitoring' => [
    'enabled' => true,
    'slow_event_threshold' => 5000, // ms
],
bash
php artisan eventbus:consume
php artisan eventbus:consume --queue=auth_ms.business_events
ini
[es = /var/www/html/%(ENV_SERVICE_NAME)s/vendor/uzapoint/eventbus-core/ops/supervisor-eventbus.conf
bash
php artisan eventbus:doctor
php artisan eventbus:doctor --skip-broker