Skip to content

Commit eff7716

Browse files
fixing-kafka-connector
1 parent 02b4042 commit eff7716

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

.env.example

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
KAFKA_QUEUE=your_kafka_topic
2-
KAFKA_BOOTSTRAP_SERVERS=localhost:9092
3-
KAFKA_SECURITY_PROTOCOL=SASL_SSL
4-
KAFKA_SASL_MECHANISMS=PLAIN
5-
KAFKA_SASL_USERNAME=your_kafka_username
6-
KAFKA_SASL_PASSWORD=your_kafka_password
7-
KAFKA_GROUP_ID=your_consumer_group
1+
KAFKA_QUEUE=<kafka-topic>
2+
KAFKA_BOOTSTRAP_SERVERS=<kafka-bootstrap-servers>
3+
KAFKA_SECURITY_PROTOCOL=<kafka-security-protocol>
4+
KAFKA_SASL_MECHANISMS=<kafka-sasl-mechanisms>
5+
KAFKA_SASL_USERNAME=<kafka-sasl-username>
6+
KAFKA_SASL_PASSWORD=<kafka-sasl-password>
7+
KAFKA_GROUP_ID=<kafka-group-id>

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
# kafka-queue
22

33
- https://arnaud-lb.github.io/php-rdkafka-doc/phpdoc/rdkafka.installation.html
4+
5+
### ServiceProvider (KafkaServiceProvider):
6+
7+
- Registers the Kafka queue connector with Laravel's queue manager.
8+
9+
### Implements the QueueContract interface.
10+
11+
- Provides methods like push, pop, and size for interacting with Kafka.
12+
- push() pushes a serialized job to Kafka using the producer.
13+
- pop() consumes messages from Kafka and processes jobs.
14+
15+
### Connector Class (KafkaConnector):
16+
17+
- Implements the ConnectorInterface.
18+
- Sets up Kafka producer and consumer.

src/Providers/KafkaServiceProvider.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@
44

55
namespace Kafka\Providers;
66

7+
use Kafka\Services\KafkaConnector;
78
use Illuminate\Support\ServiceProvider;
89

910
class KafkaServiceProvider extends ServiceProvider
1011
{
11-
public function boot()
12+
public function boot(): void
1213
{
14+
/** @var QueueManager $queue */
15+
$queue = $this->app->make('queue');
16+
17+
$queue->addConnector('kafka', static fn () => new KafkaConnector());
1318
}
1419
}

0 commit comments

Comments
 (0)