ActiveMQ教程(3)— ActiveMQ中的Queue和Topics

在ActiveMQ提供的管理页面上可以看到有两个功能页面:Queue和Topic。Queue和Topic是JMS为开发人员提供的两种不同工作机制的消息队列。 在ActiveMQ官方的解释是:

Topics

In JMS a Topic implements publish and subscribe semantics. When you publish a message it goes to all the subscribers who are interested - so zero to many subscribers will receive a copy of the message. Only subscribers who had an active subscription at the time the broker receives the message will get a copy of the message.

中文的可以译做:JMS-Topic 队列基于“订阅-发布”模式,当操作者发布一条消息后,所有对这条消息感兴趣的订阅者都可以收到它——也就是说这条消息会被拷贝成多份,进行分发。只有当前“活动的”订阅者能够收到消息(换句话说,如果当前JMS-Topic队列中没有订阅者,这条消息将被丢弃)。

Queue

A JMS Queue implements load balancer semantics. A single message will be received by exactly one consumer. If there are no consumers available at the time the message is sent it will be kept until a consumer is available that can process the message. If a consumer receives a message and does not acknowledge it before closing then the message will be redelivered to another consumer. A queue can have many consumers with messages load balanced across the available consumers.


So Queues implement a reliable load balancer in JMS.

中文的可以译做:JMS-Queue是一种“负载均衡模式”的实现。一个消息能且只能被一个消费者接受。如果当前JMS-Queue中没有任何的消费者,那么这条消息将会被Queue存储起来(实际应用中可以存储在磁盘上,也可以存储在数据库中,看软件的配置),直到有一个消费者连接上。另外,如果消费者在接受到消息后,在他断开与JMS-Queue连接之前,没有发送ack信息(可以是客户端手动发送,也可以是自动发送),那么这条消息将被发送给其他消费者。

以下表格摘自互联网上的资料,基本上把Queue和Topic这两种队列的不同特性说清楚了:
这里写图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值