Skip to content
This repository was archived by the owner on Jun 10, 2022. It is now read-only.

Problems with async & sync #237

Open
SergPavlov89 opened this issue Oct 16, 2018 · 0 comments
Open

Problems with async & sync #237

SergPavlov89 opened this issue Oct 16, 2018 · 0 comments

Comments

@SergPavlov89
Copy link

Hi, we use this code for logging email delivery.

class Kafka extends Component
{


    public $url;

    public function logger($topic, $value){

        //$logger = new Logger('my_logger');
        //$logger->pushHandler(new StdoutHandler());
        $config = \Kafka\ProducerConfig::getInstance();
        //$config->setMetadataRefreshIntervalMs(10000);
        $config->setMetadataBrokerList($this->url);
        //$config->setBrokerVersion('1.0.0');
        //$config->setRequiredAck(1);
        $config->setIsAsyn(false);
        //$config->setProduceInterval(500);
        $producer = new \Kafka\Producer(
            function() use ($topic, $value)  {
                return [
                    [
                        'topic' => $topic,
                        'value' => $value,
                    ],
                ];
            }
        );
       // $producer->setLogger($logger);
       /* $producer->success(function($result) {
            var_dump($result);
        });
        $producer->error(function($errorCode) {
           // var_dump($errorCode);
        });*/
        $producer->send(true);

    ...
$resp = \Yii::$app->kafka->logger('sendMails', json_encode($kafka));

We had some troubles when using sync requests after pushing first msg our producer cyclically sends and "ddos" our consumer. Only restart help.
When we use async requests after send first msg consumer get it normaly first time, when we send next msg consumer get first msg and stop working.

What we do wrong?

P.S.
As you see we use Kafka 1.0.0.0. PHP 7.1
Consumers on Java

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant