PHP code example of pulsarwebsocketclient / pulsarclient

1. Go to this page and download the library: Download pulsarwebsocketclient/pulsarclient 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/ */

    

pulsarwebsocketclient / pulsarclient example snippets



 use ZZQueueService\QueueService;
 
 $queueService = QueueService::getPulsarQueue([
             "url" => "111.111.0.60:8080",
             "tenant"=>"socket",
             "namespace"=>"socket_namespace",
             "topic"=>"socket_topic"
         ]);
 
 $array = ["a"=>"b","c"=>"d"];
 for ($i=0;$i<100;$i++) {
         $queueService->produceMessage($array);
         sleep(2);
   }




       $queueService = QueueService::getRedisQueue(["params"=>'tcp://192.168.33.30:6379',"qname"=>"test_redis_queue"]);
        $queueService->produceMessage("show me code");

        $queueService->consumerMessage(function($msg){
            print_r($msg);
        });