diswebru / laravel-kafka-tools
tools for mateusjunges/laravel-kafka
Installs: 16
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/diswebru/laravel-kafka-tools
Requires
- php: >=8.2
- mateusjunges/laravel-kafka: ^2.5
This package is auto-updated.
Last update: 2025-10-05 17:13:43 UTC
README
Installation
composer require diswebru/laravel-kafka-tools
Examples
Sending a message to the tests topic
use Diswebru\LaravelKafkaTools\Kafka; Kafka::publish('topic', ['message-key' => 'message-value']);
Retrieve unprocessed messages from the tests topic and terminate the process
use Diswebru\LaravelKafkaTools\Kafka; Kafka::consumer('topic', function (ConsumerMessage $message) { $data = $message->getBody(); if (!isset($data['message-key']) && $data['message-key'] != 'message-value') { // There will be no commit throw new \Exception('Error message'); } });
Retrieve unprocessed messages from the tests topic and terminate the process using mateusjunges/laravel-kafka
use Diswebru\LaravelKafkaTools\Infrastructure\Factories\ManuallyCommitterFactory; use Junges\Kafka\Contracts\ConsumerMessage; use Junges\Kafka\Facades\Kafka; Kafka::consumer() ->subscribe('topic') ->withOptions([ 'enable.auto.commit' => 'false', 'auto.offset.reset' => 'earliest' ]) ->stopAfterLastMessage() ->usingCommitterFactory(new ManuallyCommitterFactory()) ->withHandler(function (ConsumerMessage $message) { $data = $message->getBody(); if (!isset($data['message-key']) && $data['message-key'] != 'message-value') { // There will be no commit throw new \Exception('Error message'); } }) ->build() ->consume();