27 lines
1.3 KiB
Python
27 lines
1.3 KiB
Python
import pika
|
|
|
|
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost', 5672, '/', pika.PlainCredentials("user", "password")))
|
|
channel = connection.channel()
|
|
|
|
channel.queue_declare(queue='research_proposals')
|
|
|
|
proposals = [
|
|
{"acronym": "PROJ1", "title": "Project 1", "description": "Description 1", "amount": "300000"},
|
|
{"acronym": "PROJ2", "title": "Project 2", "description": "Description 2", "amount": "400000"},
|
|
{"acronym": "PROJ3", "title": "Project 3", "description": "Description 3", "amount": "250000"},
|
|
{"acronym": "PROJ4", "title": "Project 4", "description": "Description 4", "amount": "100000"},
|
|
{"acronym": "PROJ5", "title": "Project 5", "description": "Description 5", "amount": "900000"},
|
|
{"acronym": "PROJ6", "title": "Project 6", "description": "Description 6", "amount": "420000"}
|
|
]
|
|
|
|
for proposal in proposals:
|
|
result = channel.queue_declare(queue='', exclusive=True)
|
|
reply_to = result.method.queue
|
|
|
|
channel.basic_publish(exchange='',
|
|
routing_key='research_proposals',
|
|
properties=pika.BasicProperties(reply_to=reply_to),
|
|
body=f"{proposal['acronym']},{proposal['title']},{proposal['description']},{proposal['amount']}")
|
|
print(f"Proposal {proposal['acronym']} sent")
|
|
|
|
connection.close() |