有人用过pidbox.Mailbox吗?
我正在尝试做与该示例类似的事情,但该文档已经过时了。我设法获得了将消息发布到 django 传输的东西,但从那里他们从未成功收到。
我希望有人知道如何使用它,并可以向我展示如何成功调用/投射的示例。
这是我所拥有的(虚拟节点实际上什么都不做,只是打印或列出):
#node/server
mailbox = pidbox.Mailbox("test", type="direct")
connection = BrokerConnection(transport="django")
bound = mailbox(connection)
state = {"node": DummyNode(),
"connection": connection
}
node = bound.Node(state = state)
@node.handler
def list( state, **kwargs):
print 'list called'
return state["node"].list()
@node.handler
def connection_info(state, **kwargs):
return {"connection": state["connection"].info()}
@node.handler
def print_msg(state, **kwargs):
print 'Node handler!'
state["node"].print_msg(kwargs)
consumer = node.listen(channel = connection.channel())
try:
while not self.killed:
print 'Consumer Waiting'
connection.drain_events()
finally:
consumer.cancel()
和一个简单的客户。
#client:
mailbox = pidbox.Mailbox("test", type="direct")
connection = BrokerConnection(transport="django")
bound = mailbox(connection)
bound.cast(["localhost"], "print_msg", {'msg' : 'Message for you'})
info = bound.call(["test_application"],"list", callback=callback)