Solution: can not receive notification of OpenStack
2016-12-21 by muziIf you set up a AMQP connection to listen to Rabbit message queue, and can not receive any notification when connection is correct. Stucking queue may be the reason of this problem. As I proposed in ask.openstack.org, you can purge the queue to clear all the message in queue. In this way, the new message won't be stucked in the queue.
the command is:
rabiitmqctl purge_queue queue_name
please use the specified queue name like 'notifications.nova' to replace the 'queue_name'.
It is recommended to restart the services if purging queue does not help. Command example like,
/etc/init.d/neutron-service restart
the command patern is,
/etc/init.d/xxx start
/etc/init.d/xxx stop
/etc/init.d/xxx restart
Hope this blog can help you.
Listen to OpenStack Notification
在许多应用场景下,需要监听OpenStack的消息来做一些操作,从而实现事件驱动/消息驱动的业务。本文将介绍如何使用kombu库来监听OpenStack的消息,包括neutron,nova等相关类型的notification。
Kombu, AMQP, RabbitMQ
Kombu是Python的消息库,封装来许多消息的报文,支持包括AMQP等多种消息协议。而在OpenStack端,Notification的发布系统由RabbitMQ实现。为了监听OpenStack发出的Notification, 我们需要在本地用Kombu库建立一个connection, 连接到OpenStack的消息发布系统。
Terminology
在学习过程中,会遇到Exchange, Queue等术语,此处将简要介绍这些概念:
-
Producers
消息生产者,产生消息,并发送到交换器。
-
Exchanges
消息交换器,接受生产者发送过来的消息,根据对应的routing_key,来将消息路由到对应的队列。
-
Queues
队列接收来自交换器发来的消息,队列由消费者定义,自然也为消费者使用,用于存储消息。
-
Consumers
消费者从队列中读取消息,并进行处理。消费者声明和定义队列,并将队列绑定到对应的exchange上。
-
Routing ...