Tried below SPEL expression, but it fails to work. Need help!
@KafkaListener(topics = "#{Arrays.asList(${kafka.topic.helloworld}.split(',')).stream().map(p -> p+envSuffix).toArray(String[]::new)}")
Solution is: One of the way to add lambda into annotation is as follows:
In the KafkaReceiver class's method:
@Autowired TopicUtil topicUtil;
@KafkaListener(topics = "#{topicUtil.suffixTopics()}")
//In the TopicUtil - add the follwoing method
public String[] suffixTopics() {
return Arrays.asList(pTopics.split(",")).stream().map(p -> p + envSuffix).toArray(String[]::new);
}