Java 简单英语的 Broker 架构模式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23830413/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Broker architectural pattern in plain english
提问by habitats
Could someone explain the Broker patternto me in plain english? Possibly in terms of Java or a real life analogy.
有人可以用简单的英语向我解释Broker 模式吗?可能在 Java 或现实生活中的类比方面。
采纳答案by Adam Yost
Try to imagine that 10 people have messages they need to deliver. Another 10 people are expecting messages from the previous group. In an open environment, each person in the first group would have to deliver their message to the recipient manually, so each person has to visit at least one member of the second group. This is inefficient and chaotic.
试着想象 10 个人有他们需要传递的信息。另外 10 个人正在等待来自前一组的消息。在开放环境中,第一组中的每个人都必须手动将消息传递给收件人,因此每个人都必须访问第二组中的至少一个成员。这是低效和混乱的。
In broker, there is a control class (in this case the postman) who receives all the messages from group one. The broker then organizes the messages based off destination and does any operations needed, before visiting each recipient once to deliver all messages for them. This is far more efficient.
在 broker 中,有一个控制类(在本例中是邮递员),它接收来自第一组的所有消息。然后,代理根据目的地组织消息并执行所需的任何操作,然后再访问每个收件人一次以为其传递所有消息。这样效率更高。
In software design, this lets remote and heterogeneous classes communicate with each other easily. The control class has an interface which all incoming messages can interact with so a sorts of messages can be sent and interpreted correctly. Keep in mind this is not very scalable, so it loses effectiveness for larger systems.
在软件设计中,这让远程和异构类可以轻松地相互通信。控制类有一个接口,所有传入的消息都可以与之交互,因此可以正确发送和解释各种消息。请记住,这不是很可扩展,因此它对大型系统失去了有效性。
Hope this helped!
希望这有帮助!