ikilobyte/pulsar-client-php

如何批量接收消息

Closed this issue · 2 comments

        $options = new ConsumerOptions();
        $options->setConnectTimeout(3);
        $options->setTopic(self::$topic);
        $options->setSubscription(self::$sub);
        $options->setSubscriptionType(SubscriptionType::Shared);
        $options->setNackRedeliveryDelay(2);
        $options->setReceiveQueueSize(16);//设置16
        $options->setDeadLetterPolicy(2,self::$dead_topic,self::$sub);
        $consumer = new Consumer(self::$url, $options);
        $consumer->connect();

        $message = $consumer->receive(true);

返回的$message还是单个消息

$options->setReceiveQueueSize(16); 是配置协议层面,并不是批量接收消息,目前没有批量接收消息

好的