Receiving Messages

消息接收总是比发送稍复杂一些。有两种方法可以接收 Message。更简单的方法是使用轮询方法调用一次轮询一个 Message。更复杂但更常见的方法是注册一个侦听器,按需异步接收 Messages。我们将在接下来的两个子章节分别考虑每个方法的示例。

Message reception is always a little more complicated than sending. There are two ways to receive a Message. The simpler option is to poll for one Message at a time with a polling method call. The more complicated yet more common approach is to register a listener that receives Messages on-demand, asynchronously. We consider an example of each approach in the next two sub-sections.