【转】Difference between Point-To-Point and Publish/Subscribe JMS Messaging Models

本文详细对比了JMS中的两种消息传递模型:点对点(PTP)与发布/订阅(Pub/Sub)。PTP适用于每个消息仅需由一个接收者消费的情况;而Pub/Sub则允许消息被多个订阅者接收。此外还探讨了两种模型在消息处理方式、持久性及确认机制等方面的区别。

Difference between Point-To-Point and Publish/Subscribe JMS Messaging Models

Point-to-Point (PTP) and Publish/Subscribe (Pub/Sub) are two types of messaging models or messaging domains provided by JMS. Both of these have significant differences and should be used as per the application’s requirement. For instance, point-to-point messaging should be used when each message delivered by a producer should be consumed successfully by one receiver andpublish/subscribe messaging should be used when each message delivered by a producer should be consumed by zero or more receivers.

Here is a more detailed difference between the two messaging models:

 

Point-to-Point (Queue)

Publish-Subscribe (Topic)

1.Each message is addressed to a virtual channel known as QueueEach message is addressed to a virtual channel know as Topic
2.One-to-One i.e. a message delivered by a producer is consumed by only one receiverOne-to-Many i.e. a message delivered by a producer (publisher) can be consumed by zero or more receivers (subscribers)
3.A queue can have multiple receivers, but each message is consumed by only one receiverA topic can have multiple receivers and every receiver receives a copy of each message
4.Pull-based model i.e. client polls the queue for new messages and sends the requestPush-based model i.e. messages are broadcasted to all the subscribers without them having to poll the topic
5.Messages are retained in the queue until they are delivered to the receiver. The receiver can fetch the message even if it was not running when producer sent the messages.Messages are retained in the topic until they are delivered to the “current“ subscribers.There is an option to have durable subscriptions in pub-sub model which allows the subscriber to dis-connect, reconnect again and collect the messages that were delivered when it was not active.
6.The receiver acknowledges the successful processing of a message.Acknowledgment is optional.

Thus whether to use queue or topic as JMS message destination, depends solely on the requirements of a specific application.

 

转自: http://verticalhorizons.in/difference-between-point-to-point-and-publishsubscribe-jms-messaging-models/

转载于:https://www.cnblogs.com/amigo/p/5605976.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值