承接 uncleqiu/hyperf-rocketmq-sdk 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

uncleqiu/hyperf-rocketmq-sdk

最新稳定版本:v1.0.0

Composer 安装命令:

composer require uncleqiu/hyperf-rocketmq-sdk

包简介

Aliyun RocketMQ http sdk for php framework hyperf

README 文档

README

English | 中文

Introduction

Based on Alibaba Cloud aliyunmq/mq-http-sdk, the rocketmq sdk that supports the hyperf framework.

Installation

Use composer to install hyperf-rocketmq-sdk into your project:

composer require uncleqiu/hyperf-rocketmq-sdk

use composer.json

{
    "require": {
      "uncleqiu/hyperf-rocketmq-sdk": "dev-master"
    }
}

and run

composer install

Configuration

php bin/hyperf.php vendor:publish uncleqiu/hyperf-rocketmq-sdk

Example

Send a message

<?php
    $messageData = [
        'name' => 'uncleqiu',
    ];
    (new \Uncleqiu\RocketMQ\Client())->push('topic_key1', $messageData);

Consume message

You can run this command to generate a custom command line

php bin/hyperf.php gen:command TestConsumeCommand

And then write your consume logic code

<?php

declare(strict_types=1);

namespace App\Command;

use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Command\Annotation\Command;
use Psr\Container\ContainerInterface;
use Uncleqiu\RocketMQ\Client;

#[Command]
class TestConsumeCommand extends HyperfCommand
{
    public function __construct(protected ContainerInterface $container)
    {
        parent::__construct('consume:topic_one');
    }

    public function configure()
    {
        parent::configure();
        $this->setDescription('Consume the rocketmq data');
    }

    public function handle()
    {
        $this->line('Begin Consume....', 'info');
        (new Client())->consume('topic_key1', $this);
    }

    // rocketmq data consume processing logic
    public function handlerMessage($message)
    {
        $mqData = json_decode($message->getMessageBody(), true);
        // write your consume logic......
        var_dump($mqData);
    }
}

Finally, run your custom command line

php bin/hyperf.php consume:topic_one

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-13