2025-03-26 21:42:38 +07:00

22 lines
612 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from pika import ConnectionParameters, BlockingConnection
connection_params = ConnectionParameters(
host='localhost', port=5672
)
def main():
with BlockingConnection(connection_params) as conn:
with conn.channel() as ch:
ch.queue_declare(queue='messages') # Создание очереди
ch.basic_publish(
exchange='', # Режим
routing_key='messages', # В какую очередь отправлять
body="Hello world"
)
print("Message sent!")
if __name__ == '__main__':
main()