stream_producer.py 543 B

12345678910111213141516171819
  1. # -*- coding: utf-8 -*-
  2. import asyncio
  3. from rstream import Producer
  4. STREAM = 'demo-stream'
  5. USER = 'user'
  6. PWD = 'Un2yzriWm7veSDoh'
  7. HOST = 'rabbitmq.rabbitmq.svc.cluster.local'
  8. async def main():
  9. producer = Producer(host=HOST, port=5552, username=USER, password=PWD)
  10. async with producer:
  11. await producer.create_stream(STREAM)
  12. for i in range(100_000):
  13. await producer.send(STREAM, f"msg-{i}".encode())
  14. print(" [x] Sent 100k messages to stream")
  15. if __name__ == '__main__':
  16. asyncio.run(main())