Class ListenerUtils


  • public final class ListenerUtils
    extends java.lang.Object
    Listener utilities.
    Since:
    2.0
    Author:
    Gary Russell
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static ListenerType determineListenerType​(java.lang.Object listener)  
      static DeserializationException getExceptionFromHeader​(org.apache.kafka.clients.consumer.ConsumerRecord<?,​?> record, java.lang.String headerName, org.springframework.core.log.LogAccessor logger)
      Extract a DeserializationException from the supplied header name, if present.
      static java.lang.String recordToString​(org.apache.kafka.clients.consumer.ConsumerRecord<?,​?> record)
      Return the ConsumerRecord as a String; either toString() or [email protected].
      static java.lang.String recordToString​(org.apache.kafka.clients.consumer.ConsumerRecord<?,​?> record, boolean meta)
      Return the ConsumerRecord as a String; either toString() or [email protected].
      static void setLogOnlyMetadata​(boolean onlyMeta)
      Set to true to only log record metadata.
      static void unrecoverableBackOff​(org.springframework.util.backoff.BackOff backOff, java.lang.ThreadLocal<org.springframework.util.backoff.BackOffExecution> executions, java.lang.ThreadLocal<java.lang.Long> lastIntervals)
      Sleep according to the BackOff; when the BackOffExecution returns BackOffExecution.STOP sleep for the previous backOff.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • determineListenerType

        public static ListenerType determineListenerType​(java.lang.Object listener)
      • getExceptionFromHeader

        @Nullable
        public static DeserializationException getExceptionFromHeader​(org.apache.kafka.clients.consumer.ConsumerRecord<?,​?> record,
                                                                      java.lang.String headerName,
                                                                      org.springframework.core.log.LogAccessor logger)
        Extract a DeserializationException from the supplied header name, if present.
        Parameters:
        record - the consumer record.
        headerName - the header name.
        logger - the logger for logging errors.
        Returns:
        the exception or null.
        Since:
        2.3
      • setLogOnlyMetadata

        public static void setLogOnlyMetadata​(boolean onlyMeta)
        Set to true to only log record metadata.
        Parameters:
        onlyMeta - true to only log record metadata.
        Since:
        2.2.14
        See Also:
        recordToString(ConsumerRecord)
      • recordToString

        public static java.lang.String recordToString​(org.apache.kafka.clients.consumer.ConsumerRecord<?,​?> record)
        Return the ConsumerRecord as a String; either toString() or [email protected].
        Parameters:
        record - the record.
        Returns:
        the rendered record.
        Since:
        2.2.14
        See Also:
        setLogOnlyMetadata(boolean)
      • recordToString

        public static java.lang.String recordToString​(org.apache.kafka.clients.consumer.ConsumerRecord<?,​?> record,
                                                      boolean meta)
        Return the ConsumerRecord as a String; either toString() or [email protected].
        Parameters:
        record - the record.
        meta - true to log just the metadata.
        Returns:
        the rendered record.
        Since:
        2.5.4
      • unrecoverableBackOff

        public static void unrecoverableBackOff​(org.springframework.util.backoff.BackOff backOff,
                                                java.lang.ThreadLocal<org.springframework.util.backoff.BackOffExecution> executions,
                                                java.lang.ThreadLocal<java.lang.Long> lastIntervals)
        Sleep according to the BackOff; when the BackOffExecution returns BackOffExecution.STOP sleep for the previous backOff.
        Parameters:
        backOff - the BackOff to create a new BackOffExecution.
        executions - a thread local containing the BackOffExecution for this thread.
        lastIntervals - a thread local containing the previous BackOff interval for this thread.
        Since:
        2.3.12