MCPcopy Create free account
hub / github.com/N4si/microservices-python-app / main

Function main

src/notification-service/consumer.py:4–22  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2from send import email
3
4def main():
5 # rabbitmq connection
6 connection = pika.BlockingConnection(pika.ConnectionParameters(host="rabbitmq",heartbeat=0))
7 channel = connection.channel()
8
9 def callback(ch, method, properties, body):
10 err = email.notification(body)
11 if err:
12 ch.basic_nack(delivery_tag=method.delivery_tag)
13 else:
14 ch.basic_ack(delivery_tag=method.delivery_tag)
15
16 channel.basic_consume(
17 queue=os.environ.get("MP3_QUEUE"), on_message_callback=callback
18 )
19
20 print("Waiting for messages. To exit press CTRL+C")
21
22 channel.start_consuming()
23
24if __name__ == "__main__":
25 try:

Callers 1

consumer.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected