arquivei / laravel-kafka-queue-connector
Kafka queue driver for Laravel
Installs: 1 066
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 3
Open Issues: 0
Requires
- php: ^7.1.3
- illuminate/database: ^5.6
- illuminate/queue: ^5.6
- illuminate/support: ^5.6
Requires (Dev)
- phpunit/phpunit: ^7.0
README
Kafka Queue driver for Laravel
Install
-
Install librdkafka c library
$ cd /tmp $ mkdir librdkafka $ cd librdkafka $ git clone https://github.com/edenhill/librdkafka.git . $ ./configure $ make $ make install
-
Install the php-rdkafka PECL extension
$ pecl install rdkafka
-
Add the following to your php.ini file to enable the php-rdkafka extension
extension=rdkafka.so
-
Install this package via composer using:
composer require arquivei/laravel-kafka-queue-connector
-
Add queue config in section
connections
in yourconfig/queue.php
'kafka' => [ 'driver' => 'kafka', 'queue' => env('KAFKA_QUEUE', 'default'), 'brokers' => env('KAFKA_BROKERS', 'localhost'), 'sleep_on_error' => env('KAFKA_ERROR_SLEEP', 5), 'security.protocol' => env('SECURITY_PROTOCOL', 'PLAINTEXT'), 'group.id' => env('GROUP_ID', 'php-kafka'), 'sasl' => [ 'mechanisms' => env('SASL_MECHANISMS'), 'username' => env('SASL_USERNAME'), 'password' => env('SASL_PASSWORD'), ], 'consumers' => [ 'default' => YourDefaultConsumerJob::class | false, 'customs' => [ [ 'validations' => [ [ 'key' => [], 'value' => '', ], [ 'key' => [], 'value' => '', ], ], 'job' => YourConsumerJob::class, ], ], ], ],
Important
- if you want to consume events with custom structures, add
consumers
with the necessary rules
Run Tests
$ vendor/bin/phpunit tests
TODO
- Add validation for illuminate pattern in
src/Queue/Jobs/KafkaJob@getRawBody