glushkovds/laravel-kafka-queue
Laravel Kafka Queue Driver
4,763
1
| Install | |
|---|---|
composer require glushkovds/laravel-kafka-queue |
|
| Latest Version: | v0.1.3 |
| PHP: | ^8.0 |
| License: | MIT |
| Last Updated: | Oct 6, 2023 |
| Links: | GitHub · Packagist |
Maintainer: glushkovds
Laravel Kafka Queue Driver
Features
- Supports delayed jobs
- Supports retries
- Supports Laravel 10
- Supports authorization
Attention
The code this library is still dirty, there is no stable version. Use it at your own risk. Follow the updates, suggest yours.
Thanks to
- https://github.com/rapideinternet/laravel-queue-kafka - sources, it seems this lib is abandoned
- https://github.com/lukaszaleckas/laravel-kafka-queue - delayed jobs, docker environment
Installation
- Build and install librdkafka library, install pecl extension rdkafka
ENV LIBRDKAFKA_VERSION "v2.2.0"
RUN cd /tmp \
&& mkdir librdkafka \
&& cd librdkafka \
&& git clone --branch ${LIBRDKAFKA_VERSION} --depth 1 https://github.com/confluentinc/librdkafka.git . \
&& ./configure \
&& make \
&& make install \
&& rm -rf /tmp/librdkafka
RUN pecl install rdkafka
RUN docker-php-ext-enable rdkafka
- Install this package via composer using
composer require glushkovds/laravel-kafka-queue
- Add service provider to
app.php
LaravelKafka\KafkaQueueServiceProvider::class
- Add Kafka's connection to
queue.phpconfig
'kafka' => [
'driver' => 'kafka',
'broker_list' => env('KAFKA_BROKER_LIST', 'kafka:9092'),
'queue' => env('KAFKA_QUEUE', 'default'),
'heartbeat' => 5 * 1000, //Heartbeat in milliseconds
'group_name' => env('KAFKA_QUEUE_GROUP', 'default'),
'producer_timeout' => 1 * 1000, //Producer timeout in milliseconds
'consumer_timeout' => 3 * 1000, //Consumer timeout in milliseconds
'auth_login' => env('KAFKA_AUTH_LOGIN'),
'auth_mechanism' => env('KAFKA_AUTH_MECHANISM', 'PLAIN'),
'auth_password' => env('KAFKA_AUTH_PASSWORD'),
'auth_ssl_ca_location' => env('KAFKA_AUTH_SSL_CA_LOCATION'),
],
- Add credentials to
.envfile
KAFKA_BROKER_LIST=kafka1:9092,kafka2:9093
KAFKA_QUEUE=my-queue
KAFKA_QUEUE_GROUP=my-app
KAFKA_AUTH_LOGIN=
KAFKA_AUTH_PASSWORD=
More about pecl extension rdkafka
https://arnaud.le-blanc.net/php-rdkafka-doc/phpdoc/index.html
Related Packages
iivannov/elegant-laravel-worker
Elegant way to gracefully handle SIGTERM signal in Laravel queue worker
4,016
2