Interface DlqPartitionFunction

  • Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface DlqPartitionFunction
    A TriFunction that takes a consumer group, consumer record, and throwable and returns which partition to publish to the dead letter topic. Returning null means Kafka will choose the partition.
    Since:
    3.0
    Author:
    Gary Russell
    • Method Detail

      • apply

        @Nullable
        Integer apply​(String group,
                      org.apache.kafka.clients.consumer.ConsumerRecord<?,​?> record,
                      Throwable throwable)
        Apply the function.
        Parameters:
        group - the consumer group.
        record - the consumer record.
        throwable - the exception.
        Returns:
        the DLQ partition, or null.
      • determineFallbackFunction

        static DlqPartitionFunction determineFallbackFunction​(@Nullable
                                                              Integer dlqPartitions,
                                                              org.apache.commons.logging.Log logger)
        Determine the fallback function to use based on the dlq partition count if no DlqPartitionFunction bean is provided.
        Parameters:
        dlqPartitions - the partition count.
        logger - the logger.
        Returns:
        the fallback.