我会说一般不会,但它实际上取决于上下文以及您在应用程序中如何逻辑地考虑通信.
如果消息发送是偶然的一次性事件,并且后续消息完全不相关,那么如果您可以容忍成本,则为是.
如果你确实有一个冗长而合乎逻辑的交互序列,只要你不搞乱你的线程就可以在会话中完成它们.
会话实际上为一系列消息提供了工具,因此根据定义它意味着处理多个消息.
以下是文档的说法:
会话有几个目的:
Run Code Online (Sandbox Code Playgroud)* It is a factory for its message producers and consumers. * It supplies provider-optimized message factories. * It supports a single series of transactions that combine work将其生产者和消费者扩展到原子单位.
Run Code Online (Sandbox Code Playgroud)* It defines a serial order for the messages it consumes and the它产生的信息.
Run Code Online (Sandbox Code Playgroud)* It retains messages it consumes until they have been acknowledged. * It serializes execution of message listeners registered with its消息消费者.