All Projects → weiboad → Kafka Php

weiboad / Kafka Php

Licence: apache-2.0
kafka php client

Projects that are alternatives of or similar to Kafka Php

Strimzi Kafka Bridge
Apache Kafka bridge
Stars: ✭ 137 (-89.78%)
Mutual labels:  kafka, kafka-consumer
Trubka
A CLI tool for Kafka
Stars: ✭ 296 (-77.91%)
Mutual labels:  kafka, kafka-consumer
Parallel Consumer
Parallel Apache Kafka client wrapper with client side queueing, a simpler consumer/producer API with key concurrency and extendable non-blocking IO processing.
Stars: ✭ 154 (-88.51%)
Mutual labels:  kafka, kafka-consumer
Kukulcan
A REPL for Apache Kafka
Stars: ✭ 103 (-92.31%)
Mutual labels:  kafka, kafka-consumer
Librdkafka
The Apache Kafka C/C++ library
Stars: ✭ 5,617 (+319.18%)
Mutual labels:  kafka, kafka-consumer
Decaton
High throughput asynchronous task processing on Apache Kafka
Stars: ✭ 187 (-86.04%)
Mutual labels:  kafka, kafka-consumer
Qbusbridge
The Apache Kafka Client SDK
Stars: ✭ 272 (-79.7%)
Mutual labels:  kafka, kafka-consumer
Kafka Webview
Full-featured web-based Apache Kafka consumer UI
Stars: ✭ 319 (-76.19%)
Mutual labels:  kafka, kafka-consumer
Kq
Kafka-based Job Queue for Python
Stars: ✭ 530 (-60.45%)
Mutual labels:  kafka, kafka-consumer
Racecar
Racecar: a simple framework for Kafka consumers in Ruby
Stars: ✭ 327 (-75.6%)
Mutual labels:  kafka, kafka-consumer
Kattlo Cli
Kattlo CLI Project
Stars: ✭ 58 (-95.67%)
Mutual labels:  kafka, kafka-consumer
Rafka
Kafka proxy with a simple API, speaking the Redis protocol
Stars: ✭ 49 (-96.34%)
Mutual labels:  kafka, kafka-consumer
Karafka
Framework for Apache Kafka based Ruby and Rails applications development.
Stars: ✭ 1,223 (-8.73%)
Mutual labels:  kafka, kafka-consumer
Bigpipe
以Kafka为存储介质,提供异步Http RPC的中间件
Stars: ✭ 84 (-93.73%)
Mutual labels:  kafka
Node Webdollar
WebDollar Protocol - Currency of the Internet
Stars: ✭ 89 (-93.36%)
Mutual labels:  protocol
Kafka Study
关于kafka的一些相关使用示例代码。
Stars: ✭ 84 (-93.73%)
Mutual labels:  kafka
Arduino Robust Serial
A simple and robust serial communication protocol. It was designed for Arduino but can be used for other purposes (e.g. bluetooth, sockets). Implementation in C Arduino, C++, Python and Rust.
Stars: ✭ 83 (-93.81%)
Mutual labels:  protocol
Federation
Python library for abstracting social federation protocols
Stars: ✭ 93 (-93.06%)
Mutual labels:  protocol
Filodb
Distributed Prometheus time series database
Stars: ✭ 1,286 (-4.03%)
Mutual labels:  kafka
Propulsion
.NET event stream projection and scheduling platform with EventStore, CosmosDb, Equinox and Kafka integrations
Stars: ✭ 84 (-93.73%)
Mutual labels:  kafka

Kafka-php

中文文档

QQ Group Build Status Packagist Packagist Packagist GitHub issues GitHub forks GitHub stars GitHub license

Kafka-php is a pure PHP kafka client that currently supports greater than 0.8.x version of Kafka, this project v0.2.x and v0.1.x are incompatible if using the original v0.1.x You can refer to the document Kafka PHP v0.1.x Document, but it is recommended to switch to v0.2.x . v0.2.x use PHP asynchronous implementation and kafka broker interaction, more stable than v0.1.x efficient, because the use of PHP language so do not compile any expansion can be used to reduce the access and maintenance costs

Requirements

  • Minimum PHP version: 7.1
  • Kafka version greater than 0.8
  • The consumer module needs kafka broker version greater than 0.9.0

Installation

Add the lib directory to the PHP include_path and use an autoloader like the one in the examples directory (the code follows the PEAR/Zend one-class-per-file convention).

Composer Install

Simply add a dependency nmred/kafka-php to your project if you use Composer to manage the dependencies of your project.

$ composer require nmred/kafka-php

Here is a minimal example of a composer.json file :

{
	"require": {
		"nmred/kafka-php": "0.2.*"
	}
}

Configuration

Configuration properties are documented in Configuration

Producer

Asynchronous mode

<?php
require '../vendor/autoload.php';
date_default_timezone_set('PRC');
use Monolog\Logger;
use Monolog\Handler\StdoutHandler;
// Create the logger
$logger = new Logger('my_logger');
// Now add some handlers
$logger->pushHandler(new StdoutHandler());

$config = \Kafka\ProducerConfig::getInstance();
$config->setMetadataRefreshIntervalMs(10000);
$config->setMetadataBrokerList('10.13.4.159:9192');
$config->setBrokerVersion('1.0.0');
$config->setRequiredAck(1);
$config->setIsAsyn(false);
$config->setProduceInterval(500);
$producer = new \Kafka\Producer(
    function() {
        return [
            [
                'topic' => 'test',
                'value' => 'test....message.',
                'key' => 'testkey',
            ],
        ];
    }
);
$producer->setLogger($logger);
$producer->success(function($result) {
	var_dump($result);
});
$producer->error(function($errorCode) {
		var_dump($errorCode);
});
$producer->send(true);

Synchronous mode

<?php
require '../vendor/autoload.php';
date_default_timezone_set('PRC');
use Monolog\Logger;
use Monolog\Handler\StdoutHandler;
// Create the logger
$logger = new Logger('my_logger');
// Now add some handlers
$logger->pushHandler(new StdoutHandler());

$config = \Kafka\ProducerConfig::getInstance();
$config->setMetadataRefreshIntervalMs(10000);
$config->setMetadataBrokerList('127.0.0.1:9192');
$config->setBrokerVersion('1.0.0');
$config->setRequiredAck(1);
$config->setIsAsyn(false);
$config->setProduceInterval(500);
$producer = new \Kafka\Producer();
$producer->setLogger($logger);

for($i = 0; $i < 100; $i++) {
    $producer->send([
        [
            'topic' => 'test1',
            'value' => 'test1....message.',
            'key' => '',
        ],
    ]);
}

Consumer

<?php
require '../vendor/autoload.php';
date_default_timezone_set('PRC');
use Monolog\Logger;
use Monolog\Handler\StdoutHandler;
// Create the logger
$logger = new Logger('my_logger');
// Now add some handlers
$logger->pushHandler(new StdoutHandler());

$config = \Kafka\ConsumerConfig::getInstance();
$config->setMetadataRefreshIntervalMs(10000);
$config->setMetadataBrokerList('10.13.4.159:9192');
$config->setGroupId('test');
$config->setBrokerVersion('1.0.0');
$config->setTopics(['test']);
//$config->setOffsetReset('earliest');
$consumer = new \Kafka\Consumer();
$consumer->setLogger($logger);
$consumer->start(function($topic, $part, $message) {
	var_dump($message);
});

Low-Level API

Refer Example

QQ Group

Group 1: 531522091 Group 2: 657517955 QQ Group

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].