Take the 2-minute tour ×

I need to design a Swing application, which will need to send out multiple jobs as customer requested. each job is running the same shell scripts which will take 10-30 mins to return a value. (the jobs are not running on application server or as web services. )then the Swing application will need to decide what to do next according to the return value. my question is if I can use JMS to send out jobs. if not, what do you suggest I look into? multithreading....

Thank you very much!

share|improve this question

4 Answers 4

up vote 4 down vote accepted

Multi-threading is the obvious first approximation here. Take a look at SwingWorker, launch the process in a background thread, monitor the progress (as in show the user if it is still running, perhaps even a view into what is being emitted to the console), etc. These are the obvious choices.

What JMS would solve for you (and you would have to find a light weight JMS implementation that would run on the desktop) is to allow for retries and guarantees that the process runs to completion. Something that takes 20 minutes to run in a shell script doesn't sound like it is a candidate for a retry, but if it is, and it is important that the message really get through instead of just having the thread die and the process forgotten if the user closes the java application, then JMS is the type of thing to look at.

share|improve this answer
thank you for your suggestion! I will take a look at SwingWorker. –  mengmenger Feb 18 '10 at 5:00

JMS can most certainly be used in a Swing based application. If the shell scripts are to be executed on a server by a service that is listening to the JMS queue and respond on another queue or topic.

There is nothing limiting you from using JMS queues or topics in a desktop application.

share|improve this answer
I got what you said. the shell scripts will not be executed on a server by a service. this is pure swing application. I think I will look into multi-threading. thank you! –  mengmenger Feb 18 '10 at 5:01
You are indeed in need of some multi-threading in your Swing app if you want to run long tasks on the local system. –  orj Feb 19 '10 at 0:41

JMS is generally used to communicate between processes and between client/server, not really what you're looking for here, unless you're sending them out to a server to be processed, but it doesn't sound like that here. It sounds like you're looking for a work queue, such that a swing app has a button that adds a new task to the queue (where the task is running the shell script). You can then have multiple threads taking tasks of the queue and running the scripts.

share|improve this answer
thank you! I will use multi-threading. –  mengmenger Feb 18 '10 at 5:02

You may - or may not - profit from using a job scheduler, like Quartz. Maybe it's overkill, maybe it's just what you need.

share|improve this answer

Your Answer


