Skip to content
This repository was archived by the owner on Jun 10, 2022. It is now read-only.
This repository was archived by the owner on Jun 10, 2022. It is now read-only.

Key is not used for partitionning #228

Closed

Description

@mantzas

I have added the 'key' to the payload, which is the ID of one of my entities, so that i get the same entity in the same partition. Our topic has 4 partitions. Unfortunately it does not seem to work.
We expect that with the above the message will always go in one of the 4 partitions, but we have seen that the message will be send to all partitions.
Do you have any idea with this is the case?

Activity

  1. lcobucci commented on Jul 23, 2018

    @lcobucci
    Contributor

    @mantzas can you please check if #218 fulfils your needs?

  2. mantzas commented on Jul 23, 2018

    @mantzas
    Author

    @lcobucci is this not already implemented in the library?

  3. lcobucci commented on Jul 23, 2018

    @lcobucci
    Contributor

    @mantzas nope, that's why I'm asking you to check that particular branch. I'll be reviewing it further this week to integrate, but will be only available in v3.x

  4. mantzas commented on Jul 23, 2018

    @mantzas
    Author

    @lcobucci yes, this is what's needed from our side. We integrated the current code in our codebase to make this work now. We will wait until v3 to get the library then. Thanks man

  5. demyanovs commented on Jul 27, 2018

    @demyanovs

    @mantzas @lcobucci
    Currently, in order not to change this client and wait for the merge #218, you can get information directly from the broker and proceed as follows:

    $broker = \Kafka\Broker::getInstance();
    $topic_infos = $broker->getTopics();
    $topic_meta = $topic_infos[$topic_title];
    $part_nums = array_keys($topic_meta);
    if ($key) {
        $part_id = $part_nums[crc32($key) % count($part_nums)];
    } else {
        shuffle($part_nums);
        $part_id = $part_nums[0];
    }
    

    And then set partId

    $producer->send([
        [
            'topic' => $topic_title,
            'value' => $message,
            'partId' => $part_id,
        ],
    ]);
    
  6. mantzas commented on Jul 27, 2018

    @mantzas
    Author

    @demyanovs done this already based on #218. it's running in production already. thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions