zhizhong/kafka

There is no license information available for the latest version (dev-master) of this package.

help to use kafka in laravel

dev-master 2019-06-26 07:28 UTC

This package is not auto-updated.

Last update: 2024-05-24 07:22:40 UTC


README

composer require zhizhong/kafka:dev-master

Config

set kafka brokers routes in your env ,it can be a list by string

KAFKA_BROKERS=127.0.0.1:2086,127.0.0.2:2086

Usage

Producer

the easy way to produce is use help function kafka_dispatch

kafka_dispatch($topic, $msg)

Note: $msg must be an array

Consumer

$consumer = new Consumer($topic);
while (true) {
    $msg = $consumer->consume();
    print_r($msg);
}