Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import time
- import pika
- connection = pika.BlockingConnection(pika.ConnectionParameters(
- host='localhost'))
- channel = connection.channel()
- channel.queue_declare(queue='hound')
- def callback(ch, method, properties, body):
- print(" [x] Received %r" % (body,))
- time.sleep(5)
- print(" [x] Done")
- ch.basic_ack(delivery_tag = method.delivery_tag)
- channel.basic_consume(callback,
- queue='hound',
- )
- print(' [*] Waiting for messages. To exit press CTRL+C')
- channel.start_consuming()
- #include <SimpleAmqpClient/SimpleAmqpClient.h>
- using namespace AmqpClient;
- int main(int argc, char *argv[])
- {
- Channel::ptr_t channel;
- channel = Channel::Create("SERVER_HOST", SERVER_PORT,
- "LOGIN", "PASS", "/");
- BasicMessage::ptr_t msg = BasicMessage::Create("HELLO!!!");
- channel->DeclareQueue("hound");
- channel->BasicPublish("", "hound", msg, true);
- }
- terminate called after throwing an instance of 'AmqpClient::PreconditionFailedException'
- what(): channel error: 406: AMQP_QUEUE_DECLARE_METHOD caused: PRECONDITION_FAILED - parameters for queue 'hound' in vhost '/' not equivalent
- Aborted
- #!/usr/bin/env python
- import sys
- import pika
- credentials = pika.PlainCredentials(
- username=username, password=password
- )
- connection = pika.BlockingConnection(
- pika.ConnectionParameters(
- host=host,
- virtual_host=virtual_host,
- credentials=credentials,
- port=RABBIT_PORT
- )
- )
- channel = connection.channel()
- channel.queue_declare(queue='hound')
- channel.basic_publish(exchange='',
- routing_key='hound',
- body='hello!')
- print(" [x] Sent %r" % (message,))
Add Comment
Please, Sign In to add comment