{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# AMQP / RabbitMQ" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " [*] Waiting for messages. To exit press CTRL+C\n", " [x] Received b'World1!'\n", " [x] Received b'World2b!'\n", " [x] Received b'World3b!'\n", " [x] Received b'World1!'\n", " [x] Received b'World2b!'\n", " [x] Received b'World3b!'\n", " [x] Received b'World1!'\n", " [x] Received b'World2b!'\n", " [x] Received b'World3b!'\n" ] } ], "source": [ "import pika\n", "\n", "connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))\n", "channel = connection.channel()\n", "\n", "def callback(ch, method, properties, body):\n", " print(\" [x] Received %r\" % body)\n", " \n", "channel.basic_consume(callback,\n", " queue='hello',\n", " no_ack=True) \n", "\n", "print(' [*] Waiting for messages. To exit press CTRL+C')\n", "channel.start_consuming()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.1" } }, "nbformat": 4, "nbformat_minor": 2 }