Download the PHP package uncleqiu/hyperf-rocketmq without Composer

On this page you can find all versions of the php package uncleqiu/hyperf-rocketmq. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package hyperf-rocketmq

hyperf_rocketmq

基于阿里云 rocketmq SDK 封装,实现了协程、连接池、消息可靠投递 等功能

该库来源于: https://gitee.com/easy_code/hyperf-rocketmq

1、安装

producer、consumer 创建命令

需要先安装依赖

2、配置

发布配置

配置说明

配置 类型 默认值 备注
host string HTTP协议客户端接入点
access_key string AccessKey ID
secret_key string AccessKey Secret
instance_id string 实例id
pool array 连接池配置

3、创建相关数据表

如果不需要记录日志 或 消息不需要可靠投递,可以忽略这步

表说明:

mq_status_log:消息生产状态表

mq_produce_status_log:生成消息状态

mq_consume_log:消费日志

4、投递消息

Producer注解参数

字段名 类型 描述 默认值
poolName string 连接池名称。对应配置文件 rocketmq.php 中的key default
dbConnection string 数据库连接名称(用于记录生产日志) default
topic string topic
messageKey string 消息key 随机生成
messageTag string 消息标签

4.1 定义生产者相关信息

在 DemoProducer 文件中,我们可以修改 @Producer 注解对应的字段来替换对应的 poolNametopicmessageTag。就是最终投递到消息队列中的数据,所以我们可以随意改写 __construct 方法,只要最后赋值 payload 即可。

使用 @Producer 注解时需 use Uncleqiu\HyperfRocketMQ\Annotation\Producer; 命名空间;

4.2 普通投递方式

通过Uncleqiu\HyperfRocketMQ\Producer实例,即可投递消息。

4.3 消息可靠投递方式

目前,消息投递时Rocketmq返回成功响应,就视为投递成功(暂不考虑Rocketmq缓存丢失的问题)。

实现原理:先将需要投递的消息入库处理,然后再进行发送操作

  1. 执行以下命令,生成相关的数据表

  2. 使用示例

  3. 投递失败的消息,可以通过守护进程监听 mq_status_log 数据表status不等于3的消息,进行重新投递(后面实现)

5、消息消费

Consumer注解属性说明

属性 类型 描述 默认值
name string 消费名称
poolName string 连接池名称。对应配置文件 rocketmq.php 中的key default
topic string topic
groupId string 消费组id
messageTag string 消息标签
numOfMessage int 每次拉取消息数 3
waitSeconds int 轮询等待时间 3
processNums int 启动消费进程数 1
enable bool 是否初始化启动进程 true

在 DemoConsumer文件中,我们可以修改 @Consumer 注解对应的字段来替换对应的 topicgroupIdmessageTag

使用 @Consumer 注解时需 use Uncleqiu\HyperfRocketMQ\Annotation\Consumer; 命名空间;

6、事件说明

下面事件都在 Uncleqiu\HyperfRocketMQ\Event 命名空间下

事件 说明
AfterProduce 消息生产成功触发的事件
BeforeConsume 开启消费前触发的事件
AfterConsume 成功消费后触发的事件
FailToConsume 消费失败触发的事件

All versions of hyperf-rocketmq with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package uncleqiu/hyperf-rocketmq contains the following files

Loading the files please wait ....