wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes how to slow down JMS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "how to slow down JMS" Watch "how to slow down JMS" New topic
Author

how to slow down JMS

Rikko Verrijzer
Ranch Hand

Joined: Jul 22, 2003
Posts: 34
Hi,
I'm building an application which gets its requests from a JMS queue.
The problem I'm currently facing is that the JMS calls the onMessage() method faster than the application can handle the requests. Therefore I'm looking for a way to slow down the rate of the onMessage()calls. Preferably without slowing JMS in general, since this application is not the only application connecting to the JMS.
Hope that anyone has some usefull hint for this problem.
Thanks in advance
PS. slowing down the message supplier is not an option.
Rikko
Rama Yanegalla
Greenhorn

Joined: Feb 02, 2004
Posts: 2
You can slow down by cutting number in the pool ( at setup time for the Listner Port) or by using transactions.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
I see two other options:
1) Use a separate scheduler queue to trigger your MDB, and let the MDB read messages from the original queue using raw JMS. This approach let's you control the rate of message consumption more flexibly.
2) Have the MDB sleep for a while before consuming the next message. I.e. use Thread#sleep(long) before returning from the onMessage() method). This is actually forbidden by the specification, but should work regardless.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Melody Siu
Greenhorn

Joined: Nov 06, 2003
Posts: 21
Don't use MDB but write your own class to read out from queue and process.
Schedule this process to run periodically.
../Mel
 
Don't get me started about those stupid light bulbs.
 
subject: how to slow down JMS