jms + spring 怎么控制消息监听器的频率

由于要使用jms 看下资料,就是消息监听器监听消息,但是如果消息量太多,处理流程处理不过来怎么办?

public class MessageConsumer implements MessageListener {

 public   void  onMessage(Message message) {    
    System.out.println(message);    
   // 我的业务逻辑处理  可能要耗时间 ,如果消息量大,一直监听到消息 处理不过来怎么办

}    

}

是否存在可以控制的 消息监听器的设置?
就是说:队列已经有 100个消息了
我每次处理 10个消息,只有处理完一个处理下一个?

是否存在这样的设置流程?

[code="java"]







[/code]
类似于这样,把你的消息监听器放到监听器容器里面,通过“concurrentConsumers”设置并发的监听器数。

本身就是可以的吧?在同一个Session中,onMessage的调用本身就是串行化的

MessageListener的API上有这样的说明:

A MessageListener object is used to receive asynchronously delivered messages.

Each session must insure that it[color=red] passes messages serially to the listener[/color]. This means that a listener assigned to one or more consumers of the same session can assume that the [color=red]onMessage method is not called with the next message until the session has completed the last call[/color]

如果是消息队列的话,本身就是一个接一个处理的,如果你的消息太多,你可以让你的消费者采用多线程来获取一个队列。这个好像spring里面就可以配置的。

这跟频率没啥关系吧,你程序处理不了,只能优化代码了。