📜  JMS 中 PointToPoint 和发布/订阅模型的区别

📅  最后修改于: 2021-09-14 02:43:50             🧑  作者: Mango

点对点消息传递模型发布订阅消息传递模型Java消息服务 (JMS)支持的两种消息传递模块/类型/域。

这两个是支持异构系统之间异步消息传递的编程模型。

有一些重要的术语,它们将帮助我们更好地理解两种消息传递模型类型之间的区别:

  • JMS 目的地是一个临时区域,它充当客户端使用的消息的源和生成的消息的目标/目的地。
  • JMS 生产者是发送消息的 JMS 客户端。
  • JMS 使用者是接收消息的 JMS 客户端。
  • JMS 客户端既可以是消息的生产者,也可以是消息的消费者。
  • 时间依赖只是意味着如果生产者为消费者未订阅的某个主题发布了一些消息,那么消费者将不会收到该主题的消息。

让我们看看这两种消息传递模型类型之间的区别:

PointToPoint messaging-model (P2P) Publish/subscribe model(Pub sub)
Here the JMS Destination is queue. While JMS Destination in Pub sub is a topic.
Here the JMS producer is the sender. While JMS producer in Pub sub is a publisher.
Here the JMS consumer is receiver. While JMS consumer in Pub sub is a subscriber.
Here the message is received by only 1 JMS consumer. While in Pub sub, a message can be received by multiple JMS consumers.
Here the JMS consumer sends an acknowledgement to producer on receiving the message. While in Pub sub, the JMS consumer does not send any acknowledgement on receiving the message.
Here there exists a time dependency for the receiver to receive the message. While in Pub sub, there is no time dependency laid between producer-consumer.
This model is pull-based, which means that the receiver is responsible for requesting new messages to be sent by a sender. While this model is push-based, which means that the messages are automatically delivered to consumers without them having to request for new messages.
For ex. sending a fax/ voice message. For ex. newspapers.