pidbox.Mailbox使用成功吗?
有人使用过 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)
Has anyone used pidbox.Mailbox ?
I am attempting to do something similar to that example, but that documentation is way out of date. I have managed to get something that pubishes messages to a django transport but from there they never are successfuly received.
I was hoping that someone knows how to use this, and could show me an example of how to successfuly call/cast.
Here is what I have(dummy node really does nothing just prints or lists):
#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()
And a simple client.
#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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案显然是否定的。如果您看到这篇文章,我强烈建议您自己写一篇。 pidbox 的文档太少,而且现有的文档已经过时了。
The answer to this is apparently no. If you come across this post I highly recommend writing your own. There is too little documentation for pidbox, and the documentation that is there is out of date.