Home > Blockchain >  Micronaut Kafka Listener multi topic
Micronaut Kafka Listener multi topic

Time:05-25

I want to create a KakfaListener for several topics. All topics start with "masterdata", for example:

  • masterdata.product
  • masterdata.supplier

I try to implement a topic pattern but it doesn't work:

@KafkaListener(offsetReset = OffsetReset.EARLIEST)
    static class AnalyticsListener {

        @Topic(patterns="masterdata*")
        void updateAnalytics(String item, String topic) {
            received.add(topic);
        }
    }

Any suggestion?

CodePudding user response:

Your pattern matches masterdat, materdata, masetdataa, etc. The a* means zero or more a's.

Try using masterdata\.[a-z]

  • Related