aspose file tools*
The moose likes Java in General and the fly likes Running Java Processes Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Running Java Processes Question" Watch "Running Java Processes Question" New topic
Author

Running Java Processes Question

Elle Atechsy
Ranch Hand

Joined: Jan 23, 2004
Posts: 96
Hi All,

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.

Thanks,
Lulu
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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
Elle Atechsy
Ranch Hand

Joined: Jan 23, 2004
Posts: 96
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Running Java Processes Question