All Projects → lpflpf → rocketmq-client-php

lpflpf / rocketmq-client-php

Licence: Apache-2.0 license
A Php Client for Apache RocketMQ.

Programming Languages

C++
36643 projects - #6 most used programming language
PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to rocketmq-client-php

Rocketmq Spring Boot Starter
rocketmq-spring-boot-starter
Stars: ✭ 178 (+122.5%)
Mutual labels:  rocketmq
php-consul-api
PHP client implementation for the Consul API
Stars: ✭ 75 (-6.25%)
Mutual labels:  php-client
modulpos-php-api-client
PHP client for Modul.Kassa API Fiscal Service
Stars: ✭ 15 (-81.25%)
Mutual labels:  php-client
Blog
每周一篇,内容精简,不咸不淡,期盼探讨。微信公众号:芋道源码【纯源码分享公众号】
Stars: ✭ 2,327 (+2808.75%)
Mutual labels:  rocketmq
Rocketmq Client Cpp
Apache RocketMQ cpp client
Stars: ✭ 253 (+216.25%)
Mutual labels:  rocketmq
deepl-php-lib
🧠 DeepL API Client Library supporting PHP >= 7.3
Stars: ✭ 50 (-37.5%)
Mutual labels:  php-client
Rocketmq Client Python
Apache RocketMQ python client
Stars: ✭ 150 (+87.5%)
Mutual labels:  rocketmq
dynamic-threadpool
📌 强大的动态线程池框架,附带监控报警功能。支持 JDK、Tomcat、Jetty、Undertow 线程池;Dubbo、Dubbox、RabbitMQ、RocketMQ、Hystrix 消费线程池(更多框架线程池还在适配中)。内置两种使用模式:轻量级依赖配置中心以及无中间件依赖版本。
Stars: ✭ 3,609 (+4411.25%)
Mutual labels:  rocketmq
bol-retailer-php-client
PHP Client library for Bol.com Retailer API
Stars: ✭ 19 (-76.25%)
Mutual labels:  php-client
google-maps-services-php
PHP client library(SDK) for Google Maps API Web Services
Stars: ✭ 50 (-37.5%)
Mutual labels:  php-client
Rocketmq
Mirror of Apache RocketMQ
Stars: ✭ 16,152 (+20090%)
Mutual labels:  rocketmq
Rocketmq Spring Boot Starter
Spring Boot starter for RocketMQ
Stars: ✭ 243 (+203.75%)
Mutual labels:  rocketmq
reddit-api-client
A PHP client for the Reddit API
Stars: ✭ 74 (-7.5%)
Mutual labels:  php-client
Openmessaging Benchmark
OpenMessaging Benchmark Framework
Stars: ✭ 184 (+130%)
Mutual labels:  rocketmq
vault-php
Best Vault client for PHP that you can find
Stars: ✭ 57 (-28.75%)
Mutual labels:  php-client
Aliyun Ons
☁️ SDK of Node.js for Aliyun ONS. 🚀
Stars: ✭ 151 (+88.75%)
Mutual labels:  rocketmq
Easy-HotSpot
Easy HotSpot is a super easy WiFi hotspot user management utility for Mikrotik RouterOS based Router devices. Voucher printing in 6 ready made templates are available. Can be installed in any PHP/MySql enabled servers locally or in Internet web servers. Uses the PHP PEAR2 API Client by boenrobot.
Stars: ✭ 45 (-43.75%)
Mutual labels:  php-client
rocketmq-spring-boot-starter
Rocketmq spring boot starter
Stars: ✭ 17 (-78.75%)
Mutual labels:  rocketmq
picqer-php
PHP Client for the Picqer API
Stars: ✭ 16 (-80%)
Mutual labels:  php-client
keycloak-admin-client
PHP Client to connect to Keycloak admin rest apis
Stars: ✭ 57 (-28.75%)
Mutual labels:  php-client

rocketmq-client-php

A Php Client for Apache RocketMQ.

微信 f124816

dependence

INSTALL

  1. install rocketmq-client-cpp; (dist/Dockerfile is a example to build a librocketmq.so file)
  2. do shell:
    cp bin/librocketmq.so /usr/lib/; 
    mkdir /usr/include/rocketmq/ ; 
    cp include/* /usr/include/rocketmq/
  1. install php-cpp
  2. download rocketmq-client-php
    git clone https://github.com/lpflpf/rocketmq-client-php;
    cd rocketmq-client-php;
    make && make install
  1. update php.ini file, add line extension=rocketmq.so;
  2. try to run example in example directory.

Usage

to see autocompelete file.

Example

Producer Example

namespace RocketMQ;
$instanceName = "MessageQueue";

$producer = new Producer($instanceName);
$producer->setInstanceName($instanceName);
$producer->setNamesrvAddr("127.0.0.1:9876");
$producer->start();

for ($i = 0; $i < 10000; $i ++){
    $message = new Message("TopicTest", "*", "hello world $i");
    $sendResult = $producer->send($message);
    echo $sendResult->getSendStatus() . "\n";
}

PullConsumer Example

It is a good idea to save offset in local.

namespace RocketMQ;

$consumer = new PullConsumer("pullTestGroup");
$consumer->setInstanceName("testGroup");
$consumer->setTopic("TopicTest");
$consumer->setNamesrvAddr("127.0.0.1:9876");
$consumer->start();
$queues = $consumer->getQueues();

foreach($queues as $queue){
    $newMsg = true;
    $offset = 0;
    while($newMsg){
        $pullResult = $consumer->pull($queue, "*", $offset, 8);
    
        switch ($pullResult->getPullStatus()){
        case PullStatus::FOUND:
            foreach($pullResult as $key => $val){
                echo $val->getMessage()->getBody() . "\n";
            }
            $offset += count($pullResult);
            break;
        default:
            $newMsg = false;
            break;
        }
    }
}

PushConsumer Example

namespace RocketMQ;

$consumer = new PushConsumer("testGroup");
$consumer->setInstanceName("testGroup");
$consumer->setNamesrvAddr("127.0.0.1:9876");
$consumer->setThreadCount(10);
$consumer->setListenerType(MessageListenerType::LISTENER_ORDERLY);
$count = 0;
$consumer->setCallback(function ($msg) use (&$count){
    echo $msg->getMessage()->getBody() . "\n";
    $count ++;
});
$consumer->subscribe("TopicTest", "*");
$consumer->start();
$consumer->shutdown();

Docker

  1. Build rocketmq-client-cpp Container.
cd dist
docker build -t rocketmq-client-cpp:1.2.2 ./dist
  1. Build rocketmq-client-php Container
docker build -t rocketmq-client-php:1.0.0 .

TODO

  1. Manual commit an offset.
  2. Log handle. ( specify log file is no support by rocketmq-client-cpp. )
  3. Doc.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].