phpkafka
phpkafka copied to clipboard
对消费者指定分区没法操作
-
你遇到了什么问题? 消费某个主题的某个分区数据无法实现
-
Kafka 环境是自建还是云服务? 自建
-
请执行下面的命令获取环境信息。
php -v & php --ri swoole & composer info | grep longlang/phpkafka
# 粘贴到这里
[1] 71788
[2] 71789
PHP 8.0.21 (cli) (built: Jul 23 2022 15:38:15) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.21, Copyright (c) Zend Technologies
swoole
Swoole => enabled
Author => Swoole Team <[email protected]>
Version => 4.8.11
Built => Jul 23 2022 16:54:58
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 1.1.1d 10 Sep 2019
dtls => enabled
http2 => enabled
json => enabled
curl-native => enabled
pcre => enabled
c-ares => 1.14.0
zlib => 1.2.11
brotli => E16777223/D16777223
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
mysqlnd => 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
Composer could not find a composer.json file in /home/yych
To initialize a project, please create a composer.json file. See https://getcomposer.org/basic-usage
[1]- 已完成 php -v
[2]+ 已完成 php --ri swoole
- 提供最小可复现代码:
// 你的代码
#[Consumer(topic: 'test1', groupId: 'test1', autoCommit: true, nums: 1)]
class TestConsumer1 extends AbstractConsumer
{
public string $name = 'TestConsumer1';
public ?string $groupInstanceId = 'TestConsumer1';
public function consume(ConsumeMessage $message)
{
echo sprintf(
'TestConsumer1: topic:%s,key:%s,value:%s,partition:%s,time:%s',
$message->getTopic(),
$message->getKey(),
$message->getValue(),
$message->getPartition(),
microtime(true),
) . PHP_EOL;
}
}