connection = pika.BlockingConnection(pika.ConnectionParameters(host=
    'localhost'))
channel = connection.channel()
channel.exchange_declare(exchange='amq.topic', type='topic', durable=True)
for i in range(1000):
    channel.basic_publish(exchange='amq.topic', routing_key='hello', body=
        'Hello World {0}'.format(i))
time.sleep(3)
connection.close()
SparkStreaming, RabbitMQ и MQTT в python с использованием pika