Class KafkaUtils

java.lang.Object
org.springframework.kafka.support.KafkaUtils

public final class KafkaUtils extends Object
Utility methods.
Since:
2.2
Author:
Gary Russell
  • Field Details

    • MICROMETER_PRESENT

      public static final boolean MICROMETER_PRESENT
      True if micrometer is on the class path.
  • Method Details

    • returnTypeMessageOrCollectionOf

      public static boolean returnTypeMessageOrCollectionOf(Method method)
      Return true if the method return type is Message or Collection<Message<?>>.
      Parameters:
      method - the method.
      Returns:
      true if it returns message(s).
    • setConsumerGroupId

      public static void setConsumerGroupId(String groupId)
      Set the group id for the consumer bound to this thread.
      Parameters:
      groupId - the group id.
      Since:
      2.3
    • getConsumerGroupId

      public static String getConsumerGroupId()
      Get the group id for the consumer bound to this thread.
      Returns:
      the group id.
      Since:
      2.3
    • clearConsumerGroupId

      public static void clearConsumerGroupId()
      Clear the group id for the consumer bound to this thread.
      Since:
      2.3
    • determineSendTimeout

      public static Duration determineSendTimeout(Map<String,Object> producerProps, long buffer, long min)
      Return the timeout to use when sending records. If the ProducerConfig.DELIVERY_TIMEOUT_MS_CONFIG is not configured, or is not a number or a String that can be parsed as a long, the ProducerConfig default value (plus the buffer) is used.
      Parameters:
      producerProps - the producer properties.
      buffer - a buffer to add to the configured ProducerConfig.DELIVERY_TIMEOUT_MS_CONFIG to prevent timing out before the Kafka producer.
      min - a minimum value to apply after adding the buffer to the configured timeout.
      Returns:
      the timeout to use.
      Since:
      2.7