Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Facade custom options not being passed to Producer object #13

Closed
zebaroni opened this issue Nov 5, 2021 · 3 comments · Fixed by #14
Closed

[BUG] Facade custom options not being passed to Producer object #13

zebaroni opened this issue Nov 5, 2021 · 3 comments · Fixed by #14
Assignees
Labels
bug Something isn't working

Comments

@zebaroni
Copy link

zebaroni commented Nov 5, 2021

Im trying to instantiate a producer with a remote kafka broker (confluent), but the custom options that im setting on the Kafka facade are not going to the final Producer class.

$producer = Kafka::publishOn('[REMOTE_ADDRESS]', 'cleaners')
        ->withConfigOptions([
            'bootstrap.servers' => '[REMOTE_ADDRESS]',
            'metadata.broker.list' => '[REMOTE_ADDRESS]',
            'security.protocol' => 'SASL_SSL',
            'sasl.mechanisms' => 'PLAIN',
            'sasl.username' => '[API_KEY]',
            'sasl.password' => '[API_KEY]',
        ])
        ->withBodyKey("test", "test")
        ->send();

This throws an exception because these configOptions are not being passed to the Conf object from rdkafka. Probably because of this line:

Junges\Kafka\Producers\Producer.php - Line 22

        $this->producer = app(KafkaProducer::class, [
            'conf' => $this->setConf($this->config->getProducerOptions()),
        ]);

Which limits the config passed to KafkaProducer::class to be only the ones returned from getProducerOptions().

Am i doing something wrong?
It works when i try to use php-rdkafka with the same configs.

@mateusjunges
Copy link
Owner

Hello @renatobcj, i forgot the $this->customOptions array merge for producer configs. Fixing it now. Thanks for your report.

@mateusjunges
Copy link
Owner

@renatobcj #38ca04 allows you to set custom options for producers config. Released on v1.1.3. Let me know if it fixes your issue.

@mateusjunges mateusjunges self-assigned this Nov 6, 2021
@mateusjunges mateusjunges added the bug Something isn't working label Nov 6, 2021
@mateusjunges mateusjunges linked a pull request Nov 8, 2021 that will close this issue
@mateusjunges
Copy link
Owner

@renatobcj v1.2.0 should fix this problem. Please let me know if it's working well now.

@mateusjunges mateusjunges changed the title Facade custom options not being passed to Producer object [BUG] Facade custom options not being passed to Producer object Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants