greensight/laravel-phprdkafka-producer

This package is abandoned and no longer maintained. The author suggests using the ensi/laravel-phprdkafka-producer package instead.

Opiniated High Level producer for laravel-phprdkafka

0.1.0 2021-10-01 07:37 UTC

This package is auto-updated.

Last update: 2021-10-05 19:55:08 UTC


README

Deprecated, use https://github.com/ensi-platform/laravel-php-rdkafka-producer instead

Opiniated High Level producer for greensight/laravel-phprdkafka

Installation

Firstly, you have to install and configure greensight/laravel-phprdkafka

Then,

composer require greensight/laravel-phprdkafka-producer

Usage

Send a single message:

use Greensight\LaravelPhpRdKafkaProducer\HighLevelProducer;

(new HighLevelProducer($topicName))->sendOne($messageString);

Send several messages at once:

(new HighLevelProducer($topicName))->sendMany([$message1String, $message2String]);

All options with defaults:

use Greensight\LaravelPhpRdKafkaProducer\HighLevelProducer;
use Greensight\LaravelPhpRdKafkaProducer\Exceptions\KafkaProducerException;

$producer = new HighLevelProducer(
    topicName: $topicName, 
    producerName: 'some-producer-from-greensight/laravel-phprdkafka-config', 
    flushTimeout: 5000, // ms
    flushRetries: 5,
);

try {
    $producer
        ->setFlushTimeout(10000)
        ->setFlushRetries(10)
        ->sendOne($messageString);
} catch (KafkaProducerException $e) {
    //...
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

License

The MIT License (MIT). Please see License File for more information.