ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Stopping a run-away java compute node

Post new topic  Reply to topic
 Stopping a run-away java compute node « View previous topic :: View next topic » 
Author Message
rsandoz
PostPosted: Thu Nov 01, 2007 12:32 pm    Post subject: Stopping a run-away java compute node Reply with quote

Novice

Joined: 12 Oct 2006
Posts: 17

Is there a way to "stop" a java compute node.

In other words, if I have:

for (int i = 0; i < 1000; i++) {
System.out.println("Iteration " + i);
Thread.sleep(1000);
}

and I stop the containing message flow, how do I intercept the stop signal from within my Java code? I already tried Runtime.addShutdownHook(), but it seems that broker isn't sending the signal to the JVM for this to happen.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Nov 01, 2007 1:59 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

What and you have no catch around with
ThreadInterruptedException or something like that??
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
jefflowrey
PostPosted: Thu Nov 01, 2007 6:16 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

DO NOT USE sleep() in a Message Flow.

This is bad.

Bad, bad, bad.

Because if you do, then the flow doesn't respond to the broker's control at all.

For example, it won't respond to a "stop message flow" command.

Or an "undeploy message flow" command... which is necessary in order to do a "deploy message flow" command.

Bad, bad bad!

What's the requirement you are trying to fill, with this code?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
rsandoz
PostPosted: Fri Nov 02, 2007 7:00 am    Post subject: Reply with quote

Novice

Joined: 12 Oct 2006
Posts: 17

Bad, bad, bad...

What does this mean? Is this some sort of technical terminology I am unfamiliar with?

Is it "bad bad bad" because IBM's JNI calls do not support this feature (which every other broker supports)?

I only used sleep because I didn't want to post the entire contents of our project. Basically, it is running through a loop that goes for many iterations and does quite a bit of stuff. What I am looking for is the ability to stop the message flow and somehow through the JVM, intercept the "stop" signal, so I can:
(1) finish my last iteration
(2) close my connections
(3) relinquish control
Back to top
View user's profile Send private message
rsandoz
PostPosted: Fri Nov 02, 2007 7:04 am    Post subject: Reply with quote

Novice

Joined: 12 Oct 2006
Posts: 17

What I need is Java to "stop" in between the sleeps, not just keep running. At the very least, I can spawn another thread and have it monitor a file, and cleanup the call that way. This would work, but would be very inconvenient to our admins. I need a way for the broker stop command to be seen in java.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri Nov 02, 2007 7:22 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

I don't believe that the Java MB API allows you to receive notifications of when the message flow is stopped - unless this causes the onDelete method to be invoked.

I don't think that this method will be invoked at the same time as your flow is also processing an evaluate() call, but it might. If so, you can use onDelete to set an instance variable or otherwise signal the loop in evaluate() to stop.

See http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/topic/com.ibm.etools.mft.doc/as24999_.htm for some more information.

Using sleep() in the evaluate method will cause the broker to be unable to interact with your flow in any meaningful way while the sleep() is in effect.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Stopping a run-away java compute node
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.