22 lines
612 B
Python
22 lines
612 B
Python
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()
|