接口 MessageRouter

所有超级接口:
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.
另请参阅:
  • 方法概要

    修饰符和类型
    方法
    说明
    default int
    已过时。
    since 1.22.0.
    default int
    Choose a partition based on msg and the topic metadata.
  • 方法详细资料

    • choosePartition

      @Deprecated default int choosePartition(Message<?> msg)
      已过时。
      since 1.22.0. Please use choosePartition(Message, TopicMetadata) instead.
      参数:
      msg - Message object
      返回:
      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.
      参数:
      msg - message to route
      metadata - topic metadata
      返回:
      the partition to route the message.
      从以下版本开始:
      1.22.0