Go to file
2023-07-09 18:12:14 +08:00
example composer update 2023-07-09 18:12:14 +08:00
src composer update 2023-07-09 18:12:14 +08:00
.gitignore 初始化 2023-07-07 16:20:30 +08:00
composer.json composer update 2023-07-09 17:20:38 +08:00
README.md composer update 2023-07-09 18:12:14 +08:00

rocket-mq-thinkphp 适配客户端

使用说明

安装

配置

生产者

消费者

消费者执行逻辑由开发者定义,但是仍遵循如下规则:

  1. 首先在config/rocket_mq.php 文件subscribe节点配置订阅
return [
    'subscribe' => [
        //节点配置 由mq的topic.tag为标识 
        '[topic].[tag]' => [
            Test:class
        ] 
    ]
]

  1. Test:class 需要实现 tm\xls\rocketMq\thinkphp\consumer\contract\ListenerInterface 接口


namespace example;


use tm\xls\rocketMq\thinkphp\consumer\contract\ListenerInterface;
use tm\xls\rocketMq\thinkphp\consumer\message\Message;

class Consumer implements ListenerInterface
{

    private $message;

    public function __construct(Message $message)
    {
        $this->message = $message;
    }

    public function handle()
    {
        //处理订阅逻辑
    }

    public function enable(): bool
    {
        // 这边判断是否执行
        return true;
    }
}