Interface ConsumerRecordInterceptor<K,V>
- Type Parameters:
K- The key typeV- The value type
- All Superinterfaces:
io.micronaut.core.order.Ordered
public interface ConsumerRecordInterceptor<K,V>
extends io.micronaut.core.order.Ordered
Intercepts a consumed Kafka
ConsumerRecord before Micronaut binds it to a listener method.
Implementations may return the original record, return a wrapped record that preserves the consumed
record coordinates, or return null to skip listener invocation for the consumed record.
When Micronaut manages offset commits, returning null still allows the framework to advance
offsets for the consumed record according to the configured listener offset strategy.
Wrapped records must preserve the original topic, partition, and offset because Micronaut continues to use the consumed record coordinates for listener routing, retries, and offset management.
- Since:
- 6.0.0
- Author:
- Graeme Rocher
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordThe context for record interception. -
Field Summary
Fields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Method Summary
Modifier and TypeMethodDescription@Nullable ConsumerRecord<K, V> intercept(@NonNull ConsumerRecordInterceptor.InterceptionContext<K, V> interceptionContext) Intercept the consumed record before Micronaut binds it to a listener method.default booleanmatches(@NonNull io.micronaut.inject.BeanDefinition<?> beanDefinition, @NonNull io.micronaut.inject.ExecutableMethod<?, ?> method) Determine whether this interceptor applies to the given listener method.Methods inherited from interface io.micronaut.core.order.Ordered
getOrder
-
Method Details
-
matches
default boolean matches(@NonNull io.micronaut.inject.BeanDefinition<?> beanDefinition, @NonNull io.micronaut.inject.ExecutableMethod<?, ?> method) Determine whether this interceptor applies to the given listener method.- Parameters:
beanDefinition- The listener bean definitionmethod- The executable listener method- Returns:
trueif this interceptor should be applied
-
intercept
@Nullable ConsumerRecord<K,V> intercept(@NonNull ConsumerRecordInterceptor.InterceptionContext<K, V> interceptionContext) Intercept the consumed record before Micronaut binds it to a listener method.- Parameters:
interceptionContext- The interception context- Returns:
- The record to bind, or
nullto skip listener invocation
-