lpb / hyperf-rocketmq
v1.0.0
2023-07-04 14:14 UTC
Requires
- php: >=7.4
- ext-json: *
- hyperf/di: ^2.2 || ^3.0
- hyperf/event: ^2.2 || ^3.0
- hyperf/framework: ^2.2 || ^3.0
- hyperf/guzzle: ^2.2 || ^3.0
- hyperf/logger: ^2.2 || ^3.0
- hyperf/pool: ^2.2 || ^3.0
- hyperf/process: ^2.2 || ^3.0
- hyperf/server: ^2.2 || ^3.0
- hyperf/utils: ^2.2 || ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- mockery/mockery: ^1.0
- phpstan/phpstan: ^1.0
- swoole/ide-helper: ^4.5
Suggests
- swow/swow: Required to create swow components.
This package is auto-updated.
Last update: 2024-11-26 15:04:11 UTC
README
composer require lpb/hyperf-rocketmq
新建生产者
#[Producer(poolName: "default", topic: "test_topic", groupId: "test_group", messageTag: "tMsgKey", properties: ["a" => 1])] class DemoProducer extends ProducerMessage { public function __construct(array $data) { // 设置消息内容 $this->setPayload($data); } }
新建消费者
#[Consumer(name: "Consumer", poolName: "default", topic: "test_topic", groupId: "test_group", messageTag: "tMsgKey")] class DemoConsumer extends ConsumerMessage { public function consumeMessage(RocketMQMessage $message): void { var_dump($message->getMessageId()); var_dump($this->unserialize($message->getMessageBody())); var_dump($message->getPublishTime()); } }