-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Affects Version(s): 3.3.4
Describe the bug
The SpEL expression in the containerPostProcessor
of @KafkaListener
is not being evaluated correctly.
Details
I am using the @KafkaListener
annotation with a containerPostProcessor
, and I need to pass a Spring Expression Language (SpEL) expression like:
public interface RecordListener<R> extends Consumer {
@RetryableTopic(kafkaTemplate = "kafkaTemplate",
exclude = NoRetryableException.class,
dltStrategy = DltStrategy.FAIL_ON_ERROR,
attempts = "#{__listener.getContext().numberOfRetries}",
backoff = @Backoff(delay = 3000, multiplier = 2.0, maxDelay = 240000),
topicSuffixingStrategy = TopicSuffixingStrategy.SUFFIX_WITH_INDEX_VALUE)
@KafkaListener(id = "#{__listener.getContext().id}", topics = "#{__listener.getContext().topic}",
groupId = "#{__listener.getContext().groupId}", containerPostProcessor = "#{__batchListener.getContext().containerPostProcessor}",
properties = {"#{__listener.getContext().customProperties}"})
void onMessage(ConsumerRecord<String, R> record, Acknowledgment ack);
}
public interface Consumer {
ConsumerContext getContext();
}
@Data
@AllArgsConstructor
@Builder
public class ConsumerContext {
private String id;
private String groupId;
private String topicIn;
private String topicOut;
private Integer concurrency;
private Boolean autoStartup;
private ConsumerType consumerType;
private String[] customProperties;
private String containerPostProcessor;
}
However, it seems that the SpEL expression is not being evaluated. The application fails to resolve the containerPostProcessor bean, and it does not process the expression.
I got this error:
Consider defining a bean named '#{__batchListener.getContext().containerPostProcessor}' in your configuration
In KafkaListenerAnnotationBeanPostProcessor
method 'processKafkaListenerAnnotation' all KafkaListener
fileds are beeing resolved except containerPostProcessor