Interface MessageRouter

All Superinterfaces:
Serializable

@Public @Stable public interface MessageRouter extends Serializable
Interface for custom message router that can be passed to a producer to select the partition that a particular messsage should be published on.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default int
    Deprecated.
    since 1.22.0.
    default int
    Choose a partition based on msg and the topic metadata.
  • Method Details

    • choosePartition

      @Deprecated default int choosePartition(Message<?> msg)
      Deprecated.
      since 1.22.0. Please use choosePartition(Message, TopicMetadata) instead.
      Parameters:
      msg - Message object
      Returns:
      The index of the partition to use for the message
    • choosePartition

      default int choosePartition(Message<?> msg, TopicMetadata metadata)
      Choose a partition based on msg and the topic metadata.
      Parameters:
      msg - message to route
      metadata - topic metadata
      Returns:
      the partition to route the message.
      Since:
      1.22.0