def publish_activity_detection_event(self, user_id, activity_label):
     '''Publish an activity detection event to kafka
     
     user_id        The user identity token as a string
     activity_label A string representation of the activity label detected
     '''
     
     #Initialize and publish an activity detection event instance
     event = ActivityDetectionEvent(user_id, activity_label)
     self.producer.send_messages(KafkaEventsProducer.topic_activity_events, event.serialize())
 def consume_activity_event(self, timeout=-1):
     try:
         msg = self.strategy.dispense_message(timeout)
             
         assert(msg.topic == ActivityDetectionEventsConsumer.topic_activity_detection_events)
                 
         event = ActivityDetectionEvent.from_serialized(msg.value)
         
         return event
     
     except Queue.Empty:
         pass
     
     return None