Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to slow down JMS

 
Rikko Verrijzer
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Melody Siu
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use MDB but write your own class to read out from queue and process.
Schedule this process to run periodically.
../Mel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic