send_message.py 576 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env python3
  2. from MessageCorps.broker import kafka_producer
  3. from protobuf.data.ImageData_pb2 import Image
  4. from time import sleep
  5. import logging
  6. logging.basicConfig(level=logging.DEBUG)
  7. def main():
  8. producer = kafka_producer(bootstrap_servers=['localhost:9092'], topic="VideoStream")
  9. test_image = Image(
  10. image_data = b"this is just a test string",
  11. height = 10,
  12. width = 10
  13. )
  14. for frame in range(100):
  15. test_image.frame = frame
  16. producer.send(test_image)
  17. sleep(1)
  18. if __name__ == "__main__":
  19. main()