make producer infi
This commit is contained in:
+14
-11
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user