Enum MessageRoutingMode

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<MessageRoutingMode>

    @Public
    @Stable
    public enum MessageRoutingMode
    extends java.lang.Enum<MessageRoutingMode>
    Default routing mode for messages to partition.

    This logic is applied when the application is not setting a key MessageBuilder#setKey(String) on a particular message.

    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      CustomPartition
      Use custom message router implementation that will be called to determine the partition for a particular message.
      RoundRobinPartition
      If no key is provided, the producer will publish messages across all partitions in round-robin fashion to achieve maximum throughput.
      SinglePartition
      If no key is provided, The partitioned producer will randomly pick one single partition and publish all the messages into that partition.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static MessageRoutingMode valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static MessageRoutingMode[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • SinglePartition

        public static final MessageRoutingMode SinglePartition
        If no key is provided, The partitioned producer will randomly pick one single partition and publish all the messages into that partition. If a key is provided on the message, the partitioned producer will hash the key and assign message to a particular partition.
      • RoundRobinPartition

        public static final MessageRoutingMode RoundRobinPartition
        If no key is provided, the producer will publish messages across all partitions in round-robin fashion to achieve maximum throughput. Please note that round-robin is not done per individual message but rather it's set to the same boundary of batching delay, to ensure batching is effective.

        While if a key is specified on the message, the partitioned producer will hash the key and assign message to a particular partition.

      • CustomPartition

        public static final MessageRoutingMode CustomPartition
        Use custom message router implementation that will be called to determine the partition for a particular message.
    • Method Detail

      • values

        public static MessageRoutingMode[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (MessageRoutingMode c : MessageRoutingMode.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static MessageRoutingMode valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null