[原创]关于queue和topic的消息的一点不同_Tomcat, WebLogic及J2EE讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  Tomcat, WebLogic及J2EE讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 2570 | 回复: 0   主题: [原创]关于queue和topic的消息的一点不同        下一篇 
shun.zhang
注册用户
等级:上士
经验:305
发帖:14
精华:0
注册:1970-1-1
状态:离线
发送短消息息给shun.zhang 加好友    发送短消息息给shun.zhang 发消息
发表于: IP:您无权察看 2014-7-23 17:46:06 | [全部帖] [楼主帖] 楼主

topic里面消息可以被订阅,怎么订阅?和queue有什么区别?所有的订阅者看到的消息都是一样的,在queue中一个使用的是生产者和消费者的名词。虽然从概念上能够理解两者的区别,但是好像还有点不直观。

本来不知道怎么比较好的设计实验来比较二者的区别,原因一是我对这二者的编程还比较陌生,原因二是实验之前我也不知道会有什么结果,不好对比。从网上看到一个例子,是不同的用户消费

同一个消息的小例子。于是将以前的关于queue的例子稍加修改,变成一个topic的例子。

消息的格式是这样的:消费者标号 字符串(字符串中出现数字的地方代表消息的编号,不管前后)。

主要是看实验的结果,

topic
0-> topic message, do you accept it?0
1-> topic message, do you accept it?0
2-> topic message, do you accept it?0
3-> topic message, do you accept it?0
4-> topic message, do you accept it?0
5-> topic message, do you accept it?0
6-> topic message, do you accept it?0
7-> topic message, do you accept it?0
8-> topic message, do you accept it?0
9-> topic message, do you accept it?0
0-> topic message, do you accept it?1
1-> topic message, do you accept it?1
2-> topic message, do you accept it?1
3-> topic message, do you accept it?1
4-> topic message, do you accept it?1
5-> topic message, do you accept it?1
6-> topic message, do you accept it?1
7-> topic message, do you accept it?1
8-> topic message, do you accept it?1


……说明消息0(1)被10个消费者消费了,消息没有减少,就是没有从消息队列中移除。所以可以实现多人订阅。

queue
0->0 :mdb message,can you accept it?
1->1 :mdb message,can you accept it?
2->2 :mdb message,can you accept it?
3->3 :mdb message,can you accept it?
4->4 :mdb message,can you accept it?
5->5 :mdb message,can you accept it?
6->6 :mdb message,can you accept it?
7->7 :mdb message,can you accept it?
8->8 :mdb message,can you accept it?
9->9 :mdb message,can you accept it?


说明每一个消费者都消费了一个消息,消费之后,消息从消息队列里面移除了。所以是点对点的。

  jmssrc.zip (2014-07-23 17:46,  0.003 M)
该附件被下载的次数 1




赞(0)    操作        顶端 
总帖数
1
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论