Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents


Status

Current state: Under Discussion

...

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

In my organisation, we have been using kafka as the basic publish-subscribe messaging system provider. Our goal is the send event-based messages reliably and securely, and perform data synchronisation based on the messages. For us, the message keys represent some metadata which can result into the selection of same partition all the time. We have the following use case:

...

Under the circumstances, we only need a guarantee that same message won't be sent to multiple partitions. Using DefaultPartitioner, we can achieve this only with NULL keys. But since we need keys for metadata, we cannot maintain "Round-robin" like assignment of partition.


Public Interfaces

There is no requirement to change any interfaces. We simply use the existing paritioner.class config in server.properties and change the name of the FQCN to ours.

Proposed Changes

We therefore, would like to propose an extension of DefaultPartitioner, "KeylessPartitioner". The reason we believe "Keyless" is the most appropriate name is because it doesn't focus on a key. The partitioner will have code almost identical to DefaultPartitioner#partition method, except that it will simply execute the "Null Key and No Partition" logic from DefaultPartitioner. The following is the content of partition() method for our new partitioner.

...

                return Utils.toPositive(nextValue) % numPartitions;
            }


Compatibility, Deprecation, and Migration Plan

  • What impact (if any) will there be on existing users?
    There is no impact to existing users. This class does not need to be used unless someone has similar requirements.
  • If we are changing behavior how will we phase out the older behavior?
    No change in any existing behaviour, since the class usage is controlled by partitioner.class property in server.properties. We are not changing the default value.
  • If we need special migration tools, describe them here. 
    Not required.
  • When will we remove the existing behavior?
    Not required.

Rejected Alternatives

We could package our own jar and use it with every Kafka Distro, but we would like to make it part of the existing trunk and open it up to other developers for extension if necessary.