Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

FAAREN-tech/kafka-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Kafka Client

This package offers a simple Kafka-Client-Wrapper with Laravel Facades and configs

Installation

Run the following commands:

// Install the package
composer require faaren-tech/kafka-client

// Publish config
php artisan vendor:publish --provider="FaarenTech\KafkaClient\KafkaClientServiceProvider" 

Configuration Parameter

The parameters are prepared and needs to be added to your .env

FAA_KAFKA_REGISTRY_URL=XXXX
FAA_KAFKA_REGISTRY_AUTH_USER=XXXX
FAA_KAFKA_REGISTRY_AUTH_PASSWORD=XXXX

FAA_KAFKA_BROKER_URL=XXXX
FAA_KAFKA_BROKER_AUTH_USER=XXXX
FAA_KAFKA_BROKER_AUTH_PASSWORD=XXXX
FAA_KAFKA_CONSUMER_GROUP_ID=XXXX

Producer

            Producer::topic('TopicName')
                ->buildProducerWithRegistry('BodySchema', 'KeySchema')
                ->message('KeyValue', 'Data2Send', 'headers', 'partition')
                ->produce();
            Producer::flush();

Consumer

        $consumer = Consumer::topic('TopicName')
            ->buildConsumerWithRegistry('BodySchema', 'KeySchema')
            ->subscribe();

        while(true) {       
            /**
              * First Parameter, is the Timeout in ms, Second Parameter is the Auto-Decode Option 
            */
            $consumer->consume(5000, false, function($consumer, $message){
                //to "commit" the message, please use the ack method
                $consumer->ack($message);
            });
            
        }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages