Class UCentralKafkaConsumer
- java.lang.Object
-
- com.facebook.openwifi.cloudsdk.kafka.UCentralKafkaConsumer
-
public class UCentralKafkaConsumer extends Object
Kafka consumer for uCentral.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
UCentralKafkaConsumer.KafkaListener
Kafka record listener interface.static class
UCentralKafkaConsumer.KafkaRecord
Representation of Kafka record.
-
Constructor Summary
Constructors Constructor Description UCentralKafkaConsumer(UCentralClient client, String bootstrapServer, String groupId, String autoOffsetReset, long pollTimeoutMs, String stateTopic, String wifiScanTopic, String serviceEventsTopic)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addKafkaListener(String id, UCentralKafkaConsumer.KafkaListener listener)
Add/overwrite a Kafka listener with an arbitrary identifier.void
close()
Close the consumer.void
poll()
Poll for data.boolean
removeKafkaListener(String id)
Remove a Kafka listener with the given identifier, returning true if anything was actually removed.void
subscribe()
Subscribe to topic(s).void
wakeup()
Wakeup the consumer.
-
-
-
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 clientbootstrapServer
- the Kafka bootstrap servergroupId
- the Kafka consumer group IDautoOffsetReset
- the "auto.offset.reset" configpollTimeoutMs
- the poll timeout in msstateTopic
- 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.
-
-