客户端的代码最终调用文件./oslo_messaging/transport.py中类Transport的_send()函数发送调用请求,代码如下:
def _send(self, target, ctxt, message, wait_for_reply=None, timeout=None,
retry=None):
if not target.topic:
raise exceptions.InvalidTarget('A topic is required to send',
target)
return self._driver.send(target, ctxt, message,
wait_for_reply=wait_for_reply,
timeout=timeout, retry=retry)
变量message中包含了调用的函数名和参数,target定义了接收消息的服务端。在创建服务端监听的时候,会设置一个监听函数self._on_incoming(),即服务端在接收到消息的时候,会调用该函数,该函数最终调用文件./oslo_messaging/rpc/server.py中类RPCServer中的_process_incoming()函数,代码如下:
def _process_incoming(self, incoming):
message = incoming[0]