aliyunmq / mq-http-php-sdk Goto Github PK
View Code? Open in Web Editor NEWAliyun Message Queue(MQ) Http PHP SDK
License: MIT License
Aliyun Message Queue(MQ) Http PHP SDK
License: MIT License
// 处理业务逻辑
$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";
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 这个默认值要去掉
如题: 一个rocketmq customer group如何定义多个 topic,mq-http-php-sdk需要如何写?
7.0中改成了\GuzzleHttp\Client::MAJOR_VERSION
。
所以代码中使用了\GuzzleHttp\Client::VERSION
。就报错了。
composer中的配置"guzzlehttp/guzzle": ">=6.0.0"
会自动升级到7.0以上。
应该用"guzzlehttp/guzzle": "^6.0.0"
aliyunmq/mq-http-sdk/MQ/MQTransProducer.php(47)
$request = new ConsumeMessageRequest($this->instanceId, $this->topicName, $this->groupId, $numOfMessages, $this->messageTag, $waitSeconds);
这行代码用了$this->messageTag,这个类里没有messageTag属性
是我PHP版本不对吗
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
and i see the pull requests: Format Code have add ext-xmlwriter and ext-xmlreader to composer.json
is the xml warning ?
Code: NotSupport Message: the length of GID(CID) and TOPIC is too long, total length(include instance) should not longer than 119, please change another topic or another cid RequestId : 605402BE384531236C9E1205 HostId
[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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.