简体   繁体   中英

Kafka exclude topics to subscribe to

Currenly I am consuming multiple topcis by using this 'regex': ^device-*

This regex lets me subscribe to

device-gnt-q100-a
device-gnt-q100-a-commands
device-ant-q100-b
device-ant-q100-b-commands
device-ant-q535-a
device-dnq-qpo-def
device-dnq-qpo-def-commands
device-gda-qpp001-xyz
device-gda-qpp001-xyz-commands

Is it possible to somehow exclude all topics that end with -commands?

Tried without success:

^(?!device-\w*-commands)device-*
^(?!.*[-]commands$)device-.*$

This should work: ^(?!device-\w*-commands)device-*

There's a bug in the regex library used by librdkafka which fails on negative lookaheads. I found a solution that works in my case altough it is on the uggly side:

^device-.*([^s]|[^d]s|[^n]ds|[^a]nds|[^m]ands|[^m]mands|[^o]mmands|[^c]ommands)$

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM