pika - kombu not reconnecting to RabbitMQ -


i have 2 servers, call them , b. b runs rabbitmq, while connects rabbitmq via kombu. if restart rabbitmq on b, kombu connection breaks, , messages no longer delivered. have reset process on re-establish connection. there better approach, i.e. there way kombu re-connect automatically, if rabbitmq process restarted?

my basic code implementation below, in advance! :)

def start_consumer(routing_key, incoming_exchange_name, outgoing_exchange_name):     global rabbitmq_producer      incoming_exchange = kombu.exchange(name=incoming_exchange_name, type='direct')     incoming_queue = kombu.queue(name=routing_key+'_'+incoming_exchange_name, exchange=incoming_exchange, routing_key=routing_key)#, auto_delete=true)      outgoing_exchange = kombu.exchange(name=outgoing_exchange_name, type='direct')     rabbitmq_producer = kombu.producer(settings.rabbitmq_connection0, exchange=outgoing_exchange, serializer='json', compression=none, auto_declare=true)      settings.rabbitmq_connection0.connect()     if settings.rabbitmq_connection0.connected:         callbacks=[]         queues=[]          callbacks.append(callback)         # if push_queue:         #   callbacks.append(push_message_callback)         queues.append(incoming_queue)          print 'opening new *incoming* rabbitmq connection %s exchange %s queue' % (incoming_exchange.name, incoming_queue.name)         incoming_exchange(settings.rabbitmq_connection0).declare()         incoming_queue(settings.rabbitmq_connection0).declare()          print 'opening new *outgoing* rabbitmq connection %s exchange' % outgoing_exchange.name         outgoing_exchange(settings.rabbitmq_connection0).declare()          settings.rabbitmq_connection0.consumer(queues=queues, callbacks=callbacks) consumer:             while true:                 settings.rabbitmq_connection0.drain_events() 

on consumer side, kombu.mixins.consumermixin handles reconnecting when connection goes away (and heartbeats, etc., , lets write less code). there doesn't seem producermixin, unfortunately potentially dig code , adapt it...?


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo