lpb/hyperf-rocketmq

v1.0.0 2023-07-04 14:14 UTC

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());
    }
}