Skip to content

phpkafka的topic不支持正则? #40

Open
@waytoviva

Description

@waytoviva
  • 你遇到了什么问题
    topic 含正则表达式 都不能用,显示以下错误, kafka [api]里kafkaConsumer.subscribe 的第一个参数 支持正则模式订阅,
Exception 'longlang\phpkafka\Exception\KafkaErrorException' with message '[17] The request attempted to perform an operation on an invalid topic.'

in /mnt/d/proj_path/vendor/longlang/phpkafka/src/Protocol/ErrorCode.php:385

Stack trace:
#0 /mnt/d/proj_path/vendor/longlang/phpkafka/src/Broker.php(126): longlang\phpkafka\Protocol\ErrorCode::check()
  • Kafka 环境是自建还是云服务?
    自建

  • 请执行下面的命令获取环境信息。

php -v & php --ri swoole & composer info | grep longlang/phpkafka

[1] 6007
[2] 6008
PHP 7.4.3 (cli) (built: Oct  6 2020 15:47:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies

swoole

Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 4.6.7
Built => May 25 2021 21:55:02
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
openssl => OpenSSL 1.1.1f  31 Mar 2020
dtls => enabled
http2 => enabled
json => enabled
pcre => enabled
zlib => 1.2.11
mutex_timedlock => enabled
pthread_barrier => enabled
futex => 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 => On => On
swoole.unixsock_buffer_size => 8388608 => 8388608
longlang/phpkafka                  dev-master c7b5082 A kafka client. Support php-fpm and Swoole.
[1]-  Done                    php -v
[2]+  Done                    php --ri swoole
  • 提供最小可复现代码:
php

 $config = new ConsumerConfig($option);
 $config->setBroker(Yii::$app->params['KAFKA']['host']);
 $config->setTopic($this->topic); //这个值 要含正则时 才能触发

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions