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. Returningnull
means Kafka will choose the partition.- Since:
- 3.0
- Author:
- Gary Russell
-
-
Field Summary
Fields Modifier and Type Field Description static DlqPartitionFunction
ORIGINAL_PARTITION
Returns the same partition as the original recor.static DlqPartitionFunction
PARTITION_ZERO
Returns 0.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Integer
apply(String group, org.apache.kafka.clients.consumer.ConsumerRecord<?,?> record, Throwable throwable)
Apply the function.static DlqPartitionFunction
determineFallbackFunction(Integer dlqPartitions, org.apache.commons.logging.Log logger)
Determine the fallback function to use based on the dlq partition count if noDlqPartitionFunction
bean is provided.
-
-
-
Field Detail
-
ORIGINAL_PARTITION
static final DlqPartitionFunction ORIGINAL_PARTITION
Returns the same partition as the original recor.
-
PARTITION_ZERO
static final DlqPartitionFunction PARTITION_ZERO
Returns 0.
-
-
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 noDlqPartitionFunction
bean is provided.- Parameters:
dlqPartitions
- the partition count.logger
- the logger.- Returns:
- the fallback.
-
-