Any Idea ? How to cancel or destroy ?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   rachna_chadha
Posted On:   Tuesday, August 26, 2003 10:36 AM

I am sending a message to a Queue. One MDB there listens to this queue when message arrives . In the OnMessage method , I am running some command ( a batch file) My code in onmessage look like java.lang.Runtime runTime = Runtime.getRuntime(); java.lang.Process process = runTime.exec(Command2); process.waitFor(); This process may take long time( and block the thread) . Is there is any way I can cancel this task after message that initiates this gets into the queue. How can I cancel this process ? Any Idea ??    More>>


I am sending a message to a Queue. One MDB there listens to this queue when message arrives .

In the OnMessage method , I am running some command ( a batch file)

My code in onmessage look like

java.lang.Runtime runTime = Runtime.getRuntime();

java.lang.Process process = runTime.exec(Command2);

process.waitFor();


This process may take long time( and block the thread) .


Is there is any way I can cancel this task after message
that initiates this gets into the queue.


How can I cancel this process ?



Any Idea ??

   <<Less

Re: Any Idea ? How to cancel or destroy ?

Posted By:   tibi_paun  
Posted On:   Thursday, September 4, 2003 07:26 AM

Too easy.
Make a thread inside your thread, which will look to see if the process is null or not, and sleep for a second.
If the process is not null, then sleep for how long u want to wait for that process, then destroy it (with process.destroy()) no matter what.

I wanted to send u the code, too, but while u probably make 10 times more money than me, I think it's enough.

Best regards, tibi.
About | Sitemap | Contact