'spring Kafka listening to regex

I am trying to listen newly created topic with the below code, but is not working. Can you please tell me if the below code is correct?

public class KafkaMessageListener {
    private static final Logger LOGGER = LoggerFactory.getLogger(KafkaMessageListener.class);

    private final ProcessEventModel eventModel;

    @KafkaListener(topicPattern = "betsyncDataTopic*")
    public void receive(ConsumerRecord<String, String> consumerRecord) {
        LOGGER.info("received payload at '{}'", consumerRecord.timestamp());
        eventModel.process(consumerRecord.value());
    }


Solution 1:[1]

topicPattern should be betsyncDataTopic.*

when topic is created, consumer have to wait to refresh with new metadata. it takes 5 minutes because of metadata.max.age.ms default value: https://kafka.apache.org/documentation/#producerconfigs_metadata.max.age.ms

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1