GithubHelp home page GithubHelp logo

mq-http-php-sdk's People

Contributors

drpmma avatar xdkxlk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mq-http-php-sdk's Issues

Undefined property: MQ\MQTransProducer::$messageTag

aliyunmq/mq-http-sdk/MQ/MQTransProducer.php(47)

$request = new ConsumeMessageRequest($this->instanceId, $this->topicName, $this->groupId, $numOfMessages, $this->messageTag, $waitSeconds);

这行代码用了$this->messageTag,这个类里没有messageTag属性

guzzlehttp/guzzle > 7.0报错

7.0中改成了\GuzzleHttp\Client::MAJOR_VERSION
所以代码中使用了\GuzzleHttp\Client::VERSION。就报错了。

composer中的配置"guzzlehttp/guzzle": ">=6.0.0"会自动升级到7.0以上。
应该用"guzzlehttp/guzzle": "^6.0.0"

Fatal error: Uncaught Error: Call to undefined method GuzzleHttp\Exception\ConnectException::hasResponse()

[2020-12-15 03:52:07 *26589.0] ERROR php_swoole_server_rshutdown (ERRNO 503): Fatal error: Uncaught Error: Call to undefined method GuzzleHttp\Exception\ConnectException::hasResponse() in /data/wwwroot/xxx-core/vendor/aliyunmq/mq-http-sdk/MQ/Responses/MQPromise.php:45
Stack trace:
#0 /data/wwwroot/xxx-core/vendor/aliyunmq/mq-http-sdk/MQ/Http/HttpClient.php(94): MQ\Responses\MQPromise->wait()
#1 /data/wwwroot/binlog-es-core/vendor/aliyunmq/mq-http-sdk/MQ/MQConsumer.php(84): MQ\Http\HttpClient->sendRequest(Object(MQ\Requests\ConsumeMessageRequest), Object(MQ\Responses\ConsumeMessageResponse))
#2 /data/wwwroot/xxx-core/Task/Binlog.php(20): MQ\MQConsumer->consumeMessage(16, 1)
#3 /data/wwwroot/xxx-core/sw.php(94): xx\Task\Binlog::getData(16, Array, true)
#4 /data/wwwroot/xxx-core/sw.php(76): Server->getBinlogData(0)
#5 {main}
thrown in /data/wwwroot/xxx-core/vendor/aliyunmq/mq-http-sdk/MQ/Responses/MQPromise.php on line 45

composer 出错

Install & Use
Add require to your composer.json
{
"require": {
"aliyunmq/mq-http-sdk": ">=1.0.0"
}
}
Use Composer to install requires
composer install

按照上面的方式去安装,composer出现错误

composer

xml:read() warning

version: 1.0.0

log

PHP Warning: XMLReader::read(): /app/:1: parser error : Document is empty in /app/app/vendor/aliyunmq/mq-http-sdk/MQ/Responses/BaseResponse.php on line 45
PHP Warning: XMLReader::read(): cURL error 28: Resolving timed out after 3000 milliseconds (see https://curl.hax in /app/app/vendor/aliyunmq/mq-http-sdk/MQ/Responses/BaseResponse.php on line 45
PHP Warning: XMLReader::read(): ^ in /app/app/vendor/aliyunmq/mq-http-sdk/MQ/Responses/BaseResponse.php on line 45
PHP Warning: XMLReader::read(): /app/:1: parser error : Document is empty in /app/app/vendor/aliyunmq/mq-http-sdk/MQ/Common/XMLParser.php on line 11
PHP Warning: XMLReader::read(): cURL error 28: Resolving timed out after 3000 milliseconds (see https://curl.hax in /app/app/vendor/aliyunmq/mq-http-sdk/MQ/Common/XMLParser.php on line 11
PHP Warning: XMLReader::read(): ^ in /app/app/vendor/aliyunmq/mq-http-sdk/MQ/Common/XMLParser.php on line 11

other

and i see the pull requests: Format Code have add ext-xmlwriter and ext-xmlreader to composer.json

is the xml warning ?

php8.0不支持可选参数放中间了

    function __construct(HttpClient $client, $instanceId = NULL, $topicName, $consumer, $messageTag = NULL)
    {
        if (empty($topicName)) {
            throw new InvalidArgumentException(400, "TopicName is null");
        }
        if (empty($consumer)) {
            throw new InvalidArgumentException(400, "TopicName is null");
        }

        $this->instanceId = $instanceId;
        $this->topicName = $topicName;
        $this->consumer = $consumer;
        $this->messageTag = $messageTag;
        $this->client = $client;
    }

$instanceId = NULL 这个默认值要去掉

PHP 最低版本支持

Composer.json 里最低支持的PHP版本应该调到 >=7.0

在 PHP 5.x 版本上用应该有问题

image

应该很少有用 5.x 版本开发的了

事务消息,都没有进行ackMessage确认,但是服务端消息被消费了

// 处理业务逻辑
$receiptHandles = array();
foreach ($messages as $message) {
$receiptHandles[] = $message->getReceiptHandle();
printf("MessageID:%s TAG:%s BODY:%s \nPublishTime:%d, FirstConsumeTime:%d, \nConsumedTimes:%d, NextConsumeTime:%d,MessageKey:%s\n",
$message->getMessageId(), $message->getMessageTag(), $message->getMessageBody(),
$message->getPublishTime(), $message->getFirstConsumeTime(), $message->getConsumedTimes(), $message->getNextConsumeTime(),
$message->getMessageKey());
print_r($message->getProperties());
}

        // $message->getNextConsumeTime()前若不确认消息消费成功,则消息会重复消费
        // 消息句柄有时间戳,同一条消息每次消费拿到的都不一样
        print_r($receiptHandles);
        // 这里有点问题了,消费完消息后,都没有进行消费确认,可是发现服务端该消息已经非消费了(消费状态是已消费)
        exit;
        try {
            $this->consumer->ackMessage($receiptHandles);

        } catch (\Exception $e) {
            if ($e instanceof MQ\Exception\AckMessageException) {
                // 某些消息的句柄可能超时了会导致确认不成功
                printf("Ack Error, RequestId:%s\n", $e->getRequestId());
                foreach ($e->getAckMessageErrorItems() as $errorItem) {
                    printf("\tReceiptHandle:%s, ErrorCode:%s, ErrorMsg:%s\n", $errorItem->getReceiptHandle(), $errorItem->getErrorCode(), $errorItem->getErrorCode());
                }
            }
        }
        print "ack finish\n";

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.