PHP code example of lax1024git / webman-mq

1. Go to this page and download the library: Download lax1024git/webman-mq 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/ */

    

lax1024git / webman-mq example snippets


\Webman\Mq\Client::send('order_queue', ['id' => 1]);
\Webman\Mq\Client::publish('webmanmq_exchange', 'webmanmq.create', ['id' => 1]);

// 或
\Webman\Mq\MqQueue::send('order_queue', ['id' => 1]);

namespace app\queue\mq;

use Webman\Mq\Consumer;

class YourConsumer implements Consumer
{
    public string $queue = 'order_queue';

    public function consume($data): void
    {
        // 必须幂等;正常返回 → ACK;抛异常 → 延时重试
    }
}
bash
php start.php restart
# Windows: php windows.php
bash
php webman mq:stats
php webman mq:health
php webman mq:clear order_queue --status=all