Package Data | |
---|---|
Maintainer Username: | trueifnotfalse |
Package Create Date: | 2022-04-04 |
Package Last Update: | 2022-04-04 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-17 03:08:19 |
Package Statistics | |
---|---|
Total Downloads: | 1,297 |
Monthly Downloads: | 59 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Install the package via composer
composer require trueifnotfalse/lumen-kafka
Then you should register the service provider in bootstrap/app.php
$app->register(TrueIfNotFalse\LumenKafka\Providers\KafkaServiceProvider::class);
Add to config/queue.php
:
...
'monitoring' => [
'driver' => 'kafka',
'brokers' => env('KAFKA_BROKERS', 'localhost'),
'topics' => ['monitoring'],
'group_id' => env('KAFKA_GROUP_ID', 'group'),
'security_protocol' => env('KAFKA_SECURITY_PROTOCOL', 'PLAINTEXT'),
'sasl' => [
'username' => env('KAFKA_SASL_USERNAME'),
'password' => env('KAFKA_SASL_PASSWORD'),
'mechanisms' => env('KAFKA_SASL_MECHANISMS'),
],
'handler' => MonitoringHandler::class,
],
...
MonitoringHandler::class
<?php
namespace App\Handlers;
use Junges\Kafka\Contracts\KafkaConsumerMessage;
class MonitoringHandler
{
/**
* @param KafkaConsumerMessage $message
*
* @return void
*/
public function __invoke(KafkaConsumerMessage $message): void
{
print_r($message->getBody());
}
}
Run
php artisan kafka:consume monitoring