texastemplar
asked on
Throttling JMS Ques in Spring
I am developing an app that uses JMS ques in Spring. The app runs on a JBoss server. The ques are asynchronous and I am placing several messages on the que. The problem is I only want to process a couple of messages at a time. Does anyone know how I can set the que/listener so that only a few messages get sent to the listener, those messages get processed, then another couple of messages get sent to the listener and so on until Im out of messages?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
The only thing I can point to are these websites. There is a configuration example in "19.6 JMS Namespace Support" before "Table 19.3. Attributes of the JMS <jca-listener-container/> element" where you can set a prefetch parameter. With this parameter the consumer prefetches the given number of messages and waits for acknowlege (if a TransactionManager is set).
http://static.springframework.org/spring/docs/2.5.x/reference/jms.html#jms-jca-message-endpoint-manager
http://static.springframework.org/spring/docs/2.5.x/reference/jms.html#jms-namespace
I hope this helps. Otherwise I see no possibility to slow things down with spring.
manuel
http://static.springframework.org/spring/docs/2.5.x/reference/jms.html#jms-jca-message-endpoint-manager
http://static.springframework.org/spring/docs/2.5.x/reference/jms.html#jms-namespace
I hope this helps. Otherwise I see no possibility to slow things down with spring.
manuel
ASKER
I solved my problem. There is a parameter you can set in the messagelistener container defined in the spring xml file called concurrentConsumers. This limits the number of consumers. Then in each consumer use thread.sleep to slow its consumption of messages.
ASKER