PHP code example of ctzpack / zzmqtool

1. Go to this page and download the library: Download ctzpack/zzmqtool library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ctzpack / zzmqtool example snippets


  $a=PulsarClient::getInstance()
    ->setConf([
        "url" => "111.111.0.60:8080",
        "tenant"=>"socket",
        "namespace"=>"socket_namespace",
        "topic"=>"socket_topic",
    ]);
  for($i=0;$i<40;$i++) {
    $a->producerMsg(["d"=>$i,"ddd" => time()]);
    sleep(1);
  }

 PulsarClient::getInstance()
    ->setConf([
        "url" => "111.111.0.60:8080",
        "tenant"=>"socket",
        "namespace"=>"socket_namespace",
        "topic"=>"socket_topic",
        "subname"=>"ctz_test",
    ])->consumerMsg(function ($msgReceive){
        echo base64_decode($msgReceive['payload']).PHP_EOL;
        return true;
    });



$a=SwoolePulsarClient::getInstance()
    ->setConf([
        "host" => "111.111.0.60",
        "port"=>  "8080",
        "tenant"=>"socket",
        "namespace"=>"socket_namespace",
        "topic"=>"socket_topic",
        "subname"=>"ctz_test",
    ]);
for($i=0;$i<30;$i++) {
    $a->producerMsg(["ddd2"=>$i,"ddd" => date("Y-m-d H:i:s")]);
}

SwoolePulsarClient::getInstance()
    ->setConf([
        "host" => "111.111.0.60",
        "port"=>  "8080",
        "tenant"=>"socket",
        "namespace"=>"socket_namespace",
        "topic"=>"socket_topic",
        "subname"=>"ctz_test",
    ])->consumerMsg(function ($msgReceive){
        echo base64_decode($msgReceive['payload']).PHP_EOL;
        return true;
    });