This week's book giveaway is in the Other Open Source APIs forum. We're giving away four copies of Storm Applied and have Sean Allen, Peter Pathirana & Matthew Jankowski on-line! See this thread for details.
I'm still fairly a novice at Java. I have done mostly web work using WebSphere. What I would like to understand now is: what is needed on a server, that does not have WebSphere or WebLogic, to have a Java application process running in the background?
Brief Overview of Application: The application needs to run at all times to listen for IBM MQ messages via JMS, once it picks up a message it will further process the request as needed. This is strickly backend processing, so there are no GUIs needed.
I don't know the JMS APIs for receiving messages ... what happens when a message arrives? Does JMS call a method on a handler you provide or something like that?
I'd probably have one thread that picks up incoming messages as quickly as possible and just puts them into a blocking queue. Another thread can pull items from the queue and process them. Using two thread helps assure the code that accepts incoming messages is not busy processing one long enough to miss another one.
All this is provided in JDK 5 with the BlockingQueue interface and the thread pooling utilities. A thread pool with only one thread would do the job with very little effort on your part. If messages come in faster than one thread can process them, adding more threads might help.
See BlockingQueue and ThreadPoolExecutor. If you're in an older JDK, read up on the concepts and if they look interesting look up a 3rd party package like the Apache Commons Thread Pool or Doug Lea's packages.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: Jan 23, 2004
The thread pooling package was not something we thought about due to the web applications using WebSphere which handled the thread pool. This is very helpful. Thanks, Stan.