make producer infi

This commit is contained in:
2026-04-14 21:54:20 +00:00
parent 0eeefa377d
commit 7ef72a0446
+14 -11
View File
@@ -1,4 +1,5 @@
import pika
import time
import json
conn = pika.BlockingConnection(pika.ConnectionParameters("localhost"))
@@ -21,18 +22,20 @@ orders = [
"should_fail": False, "retry_count": 0},
]
for order in orders:
body = json.dumps(order)
ch.basic_publish(
exchange="orders.x",
routing_key="order.created", # as in the bindings
body=body,
properties=pika.BasicProperties(
delivery_mode=2, # persistent msg, committed to disk before ack
content_type="application/json"
while True:
for order in orders:
time.sleep(1)
body = json.dumps(order)
ch.basic_publish(
exchange="orders.x",
routing_key="order.created", # as in the bindings
body=body,
properties=pika.BasicProperties(
delivery_mode=2, # persistent msg, committed to disk before ack
content_type="application/json"
)
)
)
print(f"published order {order['order_id']}")
print(f"published order {order['order_id']}")
conn.close()