Skip to content

Consuming with Simple Client and Kafka #557

Closed
@cabralc

Description

@cabralc

I'm having some trouble consuming messages with the SimpleClient and the rdkafka transport.

Here is my config file:

return [
        'transport' => [
            'default' => 'rdkafka',
            'rdkafka' => [
                'global' => [
                    'group.id'          => 'app',
                    'bootstrap.servers' => env('KAFKA_BROKERS'),
                    'security.protocol' => 'sasl_ssl',
                    'sasl.mechanism'    => 'SCRAM-SHA-256',
                    'sasl.username'     => env('KAFFKA_USERNAME'),
                    'sasl.password'     => env('KAFKA_PASSWORD'),
                ],
                'topic'  => [
                ],
            ],
        ],
];

And here is the code I'm trying:

   /** @var \Enqueue\SimpleClient\SimpleClient $client */
    $client = new SimpleClient(config('enqueue.client'));
    $client->setupBroker();

    $message = new Message();
    $message->setScope(Message::SCOPE_MESSAGE_BUS);
    $message->setBody('message');
    $client->sendEvent('foo', $message);

    $client->bind('foo', KafkaProcessor::class, function(PsrMessage $psrMessage) {

        return PsrProcessor::ACK;
    });

    $client->consume()

Using the default config when producing it sends the message successfully to the "enqueue.default" topic. Then when consuming it creates a new topic "enqueue.app.default" and it never consumes the messages from "enqueue.default".

Am I missing something with the configuration? Or I am not understanding the difference between the app and message bus scope? Any insight would be extremely helpful. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions