|
@@ -0,0 +1,30 @@
|
|
|
+import time
|
|
|
+
|
|
|
+import rocketmq
|
|
|
+
|
|
|
+from pqai_agent import configs
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ credentials = rocketmq.Credentials()
|
|
|
+ mq_conf = configs.get()['mq']
|
|
|
+ rmq_client_conf = rocketmq.ClientConfiguration(mq_conf['endpoints'], credentials, mq_conf['instance_id'])
|
|
|
+ print(rmq_client_conf)
|
|
|
+ rmq_topic = 'agent_push_tasks'
|
|
|
+ rmq_group = 'agent_push_generate_task'
|
|
|
+ consumer = rocketmq.SimpleConsumer(rmq_client_conf, rmq_group, await_duration=5)
|
|
|
+ consumer.startup()
|
|
|
+ time.sleep(1)
|
|
|
+ consumer.subscribe(rmq_topic)
|
|
|
+ time.sleep(1)
|
|
|
+ while True:
|
|
|
+ t1 = time.time()
|
|
|
+ msgs = consumer.receive(1, 10)
|
|
|
+ if not msgs:
|
|
|
+ break
|
|
|
+ msg = msgs[0]
|
|
|
+ for msg in msgs:
|
|
|
+ msg_body = msg.body.decode('utf-8')
|
|
|
+ print(f"received message: {msg_body}")
|
|
|
+ consumer.ack(msg)
|
|
|
+ time.sleep(1)
|
|
|
+
|