pyinfra/mini_queue/put_on_queue.py
Julius Unverfehrt 4507bbb4e6 init
2022-02-14 12:05:40 +01:00

21 lines
745 B
Python

import pika
from mini_queue.utils.config import CONFIG
def put_message(parameters):
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
inp_queue = CONFIG.rabbitmq.queues.input
channel.queue_declare(queue=inp_queue, durable=True)
channel.basic_publish('',
inp_queue,
'Hello Wald!')
print(" [x] Sent something'")
connection.close()
if __name__ == "__main__":
credentials = pika.PlainCredentials(CONFIG.rabbitmq.user, CONFIG.rabbitmq.password)
parameters = pika.ConnectionParameters(host=CONFIG.rabbitmq.host, port=CONFIG.rabbitmq.port, heartbeat=CONFIG.rabbitmq.heartbeat, credentials=credentials)
put_message(parameters)