blackkked
This commit is contained in:
parent
d770e1f717
commit
9ed1c48b56
@ -5,14 +5,13 @@ from retry import retry
|
|||||||
from mini_queue.utils.config import CONFIG
|
from mini_queue.utils.config import CONFIG
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def callback(channel, method, properties, body):
|
def callback(channel, method, properties, body):
|
||||||
print("Received %r" % body)
|
print("Received %r" % body)
|
||||||
response = body
|
response = body
|
||||||
channel.basic_publish(exchange="", routing_key=CONFIG.rabbitmq.queues.output, body=response)
|
channel.basic_publish(exchange="", routing_key=CONFIG.rabbitmq.queues.output, body=response)
|
||||||
channel.basic_ack(delivery_tag=method.delivery_tag)
|
channel.basic_ack(delivery_tag=method.delivery_tag)
|
||||||
|
|
||||||
|
|
||||||
def init_params():
|
def init_params():
|
||||||
credentials = pika.PlainCredentials(CONFIG.rabbitmq.user, CONFIG.rabbitmq.password)
|
credentials = pika.PlainCredentials(CONFIG.rabbitmq.user, CONFIG.rabbitmq.password)
|
||||||
parameters = pika.ConnectionParameters(
|
parameters = pika.ConnectionParameters(
|
||||||
@ -24,7 +23,7 @@ def init_params():
|
|||||||
return parameters
|
return parameters
|
||||||
|
|
||||||
|
|
||||||
#@retry(pika.exceptions.AMQPConnectionError, delay=5, jitter=(1, 3))
|
# @retry(pika.exceptions.AMQPConnectionError, delay=5, jitter=(1, 3))
|
||||||
def consume(parameters, queue):
|
def consume(parameters, queue):
|
||||||
connection = pika.BlockingConnection(parameters)
|
connection = pika.BlockingConnection(parameters)
|
||||||
channel = connection.channel()
|
channel = connection.channel()
|
||||||
@ -32,4 +31,3 @@ def consume(parameters, queue):
|
|||||||
print(" [*] Waiting for messages. To exit press CTRL+C")
|
print(" [*] Waiting for messages. To exit press CTRL+C")
|
||||||
|
|
||||||
channel.start_consuming()
|
channel.start_consuming()
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
pika
|
pika
|
||||||
retry
|
retry
|
||||||
envyaml
|
envyaml
|
||||||
|
|||||||
@ -24,4 +24,4 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
for method_frame, _, body in channel.consume(queue=CONFIG.rabbitmq.queues.output):
|
for method_frame, _, body in channel.consume(queue=CONFIG.rabbitmq.queues.output):
|
||||||
print(json.loads(body))
|
print(json.loads(body))
|
||||||
break
|
break
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user