phpkafka
phpkafka copied to clipboard
消费进程执行一段时间后就出错 重启
- 你遇到了什么问题?

- Kafka 环境是自建还是云服务?
阿里云 kafka 服务
- 请执行下面的命令获取环境信息。
php -v & php --ri swoole & composer info | grep longlang/phpkafka
bash-5.0# php -v & php --ri swoole & composer info | grep longlang/phpkafka
[1] 166
[2] 167
PHP 8.0.13 (cli) (built: Nov 20 2021 07:13:05) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.13, Copyright (c) Zend Technologies
with Zend OPcache v8.0.13, Copyright (c), by Zend Technologies
swoole
Swoole => enabled
Author => Swoole Team <[email protected]>
Version => 4.8.9
Built => Apr 17 2022 02:42:36
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
spinlock => enabled
rwlock => enabled
openssl => OpenSSL 1.1.1n 15 Mar 2022
dtls => enabled
http2 => enabled
json => enabled
curl-native => enabled
pcre => enabled
zlib => 1.2.12
mutex_timedlock => enabled
pthread_barrier => enabled
async_redis => enabled
Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608
longlang/phpkafka v1.2.1 A kafka client. Support php-fpm and Swoole.
[1]- Done php -v
[2]+ Done php --ri swoole
- 提供最小可复现代码:
<?php
declare(strict_types=1);
namespace App\kafka;
use Hyperf\Kafka\AbstractConsumer;
use Hyperf\Kafka\Annotation\Consumer;
use longlang\phpkafka\Consumer\ConsumeMessage;
/**
* @Consumer(topic="hyperf", nums=5, groupId="hyperf", autoCommit=true)
*/
class KafkaConsumer extends AbstractConsumer
{
public function consume(ConsumeMessage $message): string
{
var_dump($message->getTopic() . ':' . $message->getKey() . ':' . $message->getValue());
}
}