impl_zmq.py里的一个方法
def _multi_send(method, context, topic, msg, timeout=None):
    """
    Wraps the sending of messages,
    dispatches to the matchmaker and sends
    message to all relevant hosts.
    """
    conf = CONF
    LOG.debug(_("%(msg)s") % {'msg': ' '.join(map(pformat, (topic, msg)))})    queues = matchmaker.queues(topic)
    LOG.debug(_("Sending message(s) to: %s"), queues)    # Don't stack if we have no matchmaker results
    if len(queues) == 0:
        LOG.warn(_("No matchmaker results. Not casting."))
        # While not strictly a timeout, callers know how to handle
        # this exception and a timeout isn't too big a lie.
        raise rpc_common.Timeout, "No match from matchmaker."    # This supports brokerless fanout (addresses > 1)
    for queue in queues:
        (_topic, ip_addr) = queue
        _addr = "tcp://%s:%s" % (ip_addr, conf.rpc_zmq_port)        if method.__name__ == '_cast':
            eventlet.spawn_n(method, _addr, context,
                             _topic, _topic, msg, timeout)
            return
        return method(_addr, context, _topic, _topic, msg, timeout)最后一段为什么可以广播消息到不同的地址,不是第一次调用就返回了吗?OpenStack

解决方案 »

  1.   

    很好的问题!感觉这段代码应该是有问题的。实际上,在rpc代理抽象层(RpcProxy)实现中,multicall的返回应该是iterator。参考kombu/amqp实现(MulticallWaiter)就可以知道,在对这个返回的迭代器每一次迭代/调用时,可以得到相应的rpc call结果。zeromq这个multicall实现直接就return了,而不是一个迭代器的实现。multical似乎没有看到在openstack什么项目中用,一般就是call或cast,所以这块代码实际也没有被用到。你可以写个patch修复一下。:)