| Summary | How to kill an Orbix process using the Java API |
|---|---|
| Article Number | 28849 |
| Environment | Orbacus 6.x Java Runtime All Supported Platforms |
| Question/Problem Description |
It is possible to kill an Orbix process using these commands? itadmin process kill <<name>> itadmin process kill -force <<name>> |
| Clarifying Information | |
| Error Message | |
| Defect/Enhancement Number | |
| Cause | |
| Resolution | These commands can be run using the Java Api following these steps: 1. Initialize the Orb. 2. Create a reference to the IT_Locator. 3. Using the IT_Locator, retrieve a reference to the Active Process Registry. 4. Using the registry, find the process. To Kill the process: 5. run process.kill() To Force Kill the process: 5. Narrow the process object into an Active Process Force Kill object. 6. run process.killWithForce(0) An example of this is below. Example code to kill the BankDemoProcess: package bankDemo; import org.omg.CORBA.ORB; import org.omg.PortableServer.POA; import org.omg.PortableServer.POAHelper; import org.omg.PortableServer.POAManager; import com.iona.corba.IT_LocatorAdmin.ActiveProcessForceKill; public class KillScript { public static ORB global_orb = null; public static void main(String[] args) { //Initialize the Orb. global_orb = ORB.init(args, null); ActiveProcessRegistry registry = null; try { //Create a reference to the IT_Locator. org.omg.CORBA.Object obj = global_orb.resolve_initial_references("IT_Locator"); com.iona.corba.IT_Location.Locator locator = com.iona.corba.IT_Location.LocatorHelper.narrow(obj); obj = locator.resolve_service(com.iona.corba.IT_LocatorAdmin.ACTIVE_PROCESS_REGISTRY.value); //Using the IT_Locator, retrieve a reference to the Active Process Registry. registry = com.iona.corba.IT_LocatorAdmin.ActiveProcessRegistryHelper.narrow(obj); } catch (Exception e) {} //Using the registry, find the process. com.iona.corba.IT_LocatorAdmin.ActiveProcess process = registry.find("ORBBankDemoProcess"); // process.kill(0); // use process.kill(0) to kill the process at this point //Narrow the process to a ActiveProcessForceKill com.iona.corba.IT_LocatorAdmin.ActiveProcessForceKill process1 = com.iona.corba.IT_LocatorAdmin.ActiveProcessForceKillHelper.narrow(process); System.out.println("Attempting to kill"); if (process1 instanceof com.iona.corba.IT_LocatorAdmin.ActiveProcessForceKill) { ActiveProcessForceKill forceKill = (ActiveProcessForceKill)process1; System.out.println("Process can be force-killed."); forceKill.killWithForce(0); } else { System.out.println("Process can not be force-killed. Using normal kill method."); process.kill(0); } process._release(); } } |
| Workaround | |
| Notes | |
| Attachment |
| Created date: | 17 February 2012 |
|---|---|
| Last Modified: | 13 February 2013 |
| Last Published: | 12 May 2012 |
| First Published date: | 24 February 2012 |
#KnowledgeDocs
#Orbacus