import pika connection = pika.BlockingConnection(pika.ConnectionParameters('localhost', 5672, '/', pika.PlainCredentials("user", "password"))) channel = connection.channel() channel.queue_declare(queue='research_proposals') print("Waiting for proposals...") def process_proposal(ch, method, properties, body): proposal = body.decode() acronym, title, description, amount = proposal.split(',') if 200000 <= int(amount) <= 500000: channel.basic_publish(exchange='', routing_key=properties.reply_to, properties=pika.BasicProperties(correlation_id=properties.correlation_id), body="approved") project_info=f"{acronym},{title},{description},{amount}" channel.basic_publish(exchange='', routing_key='approved_projects', body=project_info) print(f"{acronym} approved") else: channel.basic_publish(exchange='', routing_key=properties.reply_to, properties=pika.BasicProperties(correlation_id=properties.correlation_id), body="rejected") print(f"{acronym} rejected") channel.basic_consume(queue='research_proposals', on_message_callback=process_proposal, auto_ack=True) channel.start_consuming()