JMS MessageConsumer的messageListener是推还是拉? [英] JMS MessageConsumer's messageListener makes push or pull?

查看:417
本文介绍了JMS MessageConsumer的messageListener是推还是拉?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在队列MessageConsumer对象上设置messageListener时,实际上发生了什么. MessageConsumer对象是否在场景中进行某种轮询,或者这是JMS服务器真正进行的推送?

What really happens under the hood when i set a messageListener on my queue MessageConsumer object. Does the MessageConsumer object make some sort of polling ehind the scene or this is a real push made by the JMS server?

David A. Chappell,Richard Monson-Haefel和Mark Richards撰写的Java消息服务(O'Reilly Java系列),第10章第1章:点对点

Java Message Service (O'Reilly Java Series) by David A. Chappell, Richard Monson-Haefel and Mark Richards, p10 CHAPTER1: Point-to-point

点对点消息传递模型传统上是基于拉式或基于轮询的模型,在这种模型中,消息是从队列中请求的,而不是自动发送到客户端的

http://docs.oracle.com/javaee/1.4/tutorial/doc/JMS4.html#wp79175

开始传递消息时,只要传递消息,JMS提供程序就会自动调用消息侦听器的onMessage方法.

谢谢, 柯德

推荐答案

这两个并不矛盾. P2P本质上是基于拉的,因为一旦生产者发送了消息,接收者有责任读取消息.您在第二个引号中提到的onMessage()方法是用于启动请求的 notification 机制.这些变体也称为接收JMS消息的同步与异步模式,例如在

These two do not contradict each other. P2P is essentially pull-based, in that it is receiver's responsibility to read a message once it is sent by a producer. onMessage() method that you mentioned in your 2nd quote is a notification mechanism used to initiate the pull. These variations also referred to as sync vs async modes of receiving JMS messages, as for example in this chapter in Java Tutorial.

这篇关于JMS MessageConsumer的messageListener是推还是拉?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆