Skip to content

Commit 151df54

Browse files
committed
Removes improper configs
Some producer configs were being passed to the consumer and vice versa. Such improper configs were causing some configuration warnings. This commit fixes the configs and removes the problem causing the warnings.
1 parent c0647a9 commit 151df54

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

dev/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM joesantos386/laravel:php7.4-v1.5.2-4.0.4-8
1+
FROM joesantos386/laravel:8.0-v1.5.3-5.0.0-8
22

33
RUN apk add libzip-dev
44

src/Consumer.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public function __construct(Config $config)
4848

4949
public function consume(): void
5050
{
51-
$this->consumer = new KafkaConsumer($this->setConf());
52-
$this->producer = new Producer($this->setConf());
51+
$this->consumer = new KafkaConsumer($this->setConsumerConf());
52+
$this->producer = new Producer($this->setProducerConf());
5353

5454
$this->committer = CommitterBuilder::withConsumer($this->consumer)
5555
->andRetry(new NativeSleeper(), $this->config->getMaxCommitRetries())
@@ -71,13 +71,12 @@ private function doConsume()
7171
$this->handleMessage($message);
7272
}
7373

74-
private function setConf(): Conf
74+
private function setConsumerConf(): Conf
7575
{
7676
$conf = new Conf();
7777
$conf->set('auto.offset.reset', 'smallest');
7878
$conf->set('queued.max.messages.kbytes', '10000');
7979
$conf->set('enable.auto.commit', 'false');
80-
$conf->set('compression.codec', 'gzip');
8180
$conf->set('max.poll.interval.ms', '86400000');
8281
$conf->set('group.id', $this->config->getGroupId());
8382
$conf->set('bootstrap.servers', $this->config->getBroker());
@@ -92,6 +91,22 @@ private function setConf(): Conf
9291
return $conf;
9392
}
9493

94+
private function setProducerConf(): Conf
95+
{
96+
$conf = new Conf();
97+
$conf->set('compression.codec', 'gzip');
98+
$conf->set('bootstrap.servers', $this->config->getBroker());
99+
$conf->set('security.protocol', $this->config->getSecurityProtocol());
100+
101+
if ($this->config->isPlainText() && $this->config->getSasl() !== null) {
102+
$conf->set('sasl.username', $this->config->getSasl()->getUsername());
103+
$conf->set('sasl.password', $this->config->getSasl()->getPassword());
104+
$conf->set('sasl.mechanisms', $this->config->getSasl()->getMechanisms());
105+
}
106+
107+
return $conf;
108+
}
109+
95110
private function executeMessage(Message $message): void
96111
{
97112
try {

0 commit comments

Comments
 (0)