Class UCentralKafkaConsumer


  • public class UCentralKafkaConsumer
    extends Object
    Kafka consumer for uCentral.
    • Constructor Detail

      • UCentralKafkaConsumer

        public UCentralKafkaConsumer​(UCentralClient client,
                                     String bootstrapServer,
                                     String groupId,
                                     String autoOffsetReset,
                                     long pollTimeoutMs,
                                     String stateTopic,
                                     String wifiScanTopic,
                                     String serviceEventsTopic)
        Constructor.
        Parameters:
        client - an instance of the UCentral API client
        bootstrapServer - the Kafka bootstrap server
        groupId - the Kafka consumer group ID
        autoOffsetReset - the "auto.offset.reset" config
        pollTimeoutMs - the poll timeout in ms
        stateTopic - the uCentral state topic (or empty/null to skip)
        wifiScanTopic - the uCentral wifiscan topic (or empty/null to skip)
        serviceEventsTopic - the uCentral service_events topic (required)
    • Method Detail

      • subscribe

        public void subscribe()
        Subscribe to topic(s).
      • poll

        public void poll()
        Poll for data.
      • addKafkaListener

        public void addKafkaListener​(String id,
                                     UCentralKafkaConsumer.KafkaListener listener)
        Add/overwrite a Kafka listener with an arbitrary identifier. The "id" string determines the order in which listeners are called.
      • removeKafkaListener

        public boolean removeKafkaListener​(String id)
        Remove a Kafka listener with the given identifier, returning true if anything was actually removed.
      • wakeup

        public void wakeup()
        Wakeup the consumer.
      • close

        public void close()
        Close the consumer.