Can not receive neutron notification while can receive nova notification

asked 2016-12-07 17:05:49 -0600

chengli gravatar image

Hi all,

I implemented AMQP connection to listen OpenStack notification by kombu. Now, we can receive the nova notification right now. However, we can not receive neutron notification. The code shows below. Before we upgrade the OpenStack, our code can work, while it does not work after we upgrade the OpenStack. Thank you for your time.

class Worker(ConsumerMixin):
    event_queues = [
              Exchange('neutron', 'topic', durable=False),
              durable=False, routing_key='#'),
              Exchange('nova', 'topic', durable=False),
              durable=False, routing_key='#'),

    def __init__(self, connection):
        self.connection = connection

    def set_env(self, env, inventory_collection):
        inv = InventoryMgr()
        self.handler = EventHandler(env, inventory_collection)
        self.notification_responses = {
            "compute.instance.create.end": self.handler.instance_add,
            "network.create.end": self.handler.network_create,
            "network.update.end": self.handler.network_update,


    def get_consumers(self, Consumer, channel):
        return [Consumer(queues=self.event_queues,

    def process_task(self, body, message):
        f = open("./listener.log", "a")
        f.write(body['oslo.message'] + "\n")
        if "event_type" in body:
            self.handle_event(body["event_type"], body)
        elif "event_type" in body['oslo.message']:
            msg = json.loads(body['oslo.message'])
            print("event_type:", msg['event_type'])
            self.handle_event(msg['event_type'], msg)

    def handle_event(self, type, notification):
        print("got notification, event_type: " + type + '\n' + str(notification))
        if type not in self.notification_responses.keys():
            return ""
        return self.notification_responses[type](notification)

if __name__ == '__main__':
    logger = Logger()
    from kombu import Connection
    args = get_args()
    conf = Configuration(args.mongo_config)
    env = args.env
    amqp_config = conf.get("AMQP")
    host = amqp_config["host"]
    port = amqp_config["port"]
    user = amqp_config["user"]
    pwd = amqp_config["password"]
    connect_url = 'amqp://' + user + ':' + pwd + '@' + host + ':' + port + '//'
    with Connection(connect_url) as conn:
            worker = Worker(conn)
            worker.set_env(env, args.inventory)
        except KeyboardInterrupt:
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-12-19 18:29:56 -0600

chengli gravatar image

updated 2016-12-19 18:30:10 -0600

Problem solved! The reason is about the message in the Queue. They are too many messages in the queue. Purge the message in queue, and then we can receive the nitification. you can use the

rabbitmqctl purge_queue queue_name

to purge the queue.

edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2016-12-07 17:05:49 -0600

Seen: 370 times

Last updated: Dec 19 '16