Unshared CORBA server process does not exit when the client exits
Question:
Using the VB Java 3.3 bank example on IRIX. Registered bank server with OADJ as unshared server.
When client is started, OADJ spawns the bank server. But then when the client dies, the unshared server does not exit, instead it takes up over 90% of the CPU.
This does not occur if server is registered shared with the OADJ.
Answer:
This is a known problem which wasn't stated clearly in the Release Notes. In the Release notes, under Irix, it states that the ORB::shutdown() method has no effect (The implementation of Java thread interrupts doesn't do anything in the Irix implementation of the VM).
VisiBroker uses the ORB::shutdown() method in the implementation of our unshared servers and so it doesn't work.
One trick that might work given the above problem is to install an
interceptor that calls System.exit() when the shutdown interceptor
fires.
oadutil reg -r IDL:Bank/AccountManager:1.0 -o BankManager
-java Server -p unshared -a "-ORBservices" -a "exit"
Make sure that package "exit" is in the classpath of OADJ and the server so that the interceptor can be loaded when the server os spawned.
A simple example interceptor:
ExitServerIntercpetor.java
package exit;
import com.visigenic.vbroker.interceptor.*;
import com.visigenic.vbroker.GIOP.*;
public class ExitServerInterceptor
extends DefaultServerInterceptor
implements ServerInterceptor
{
public void shutdown(
com.visigenic.vbroker.interceptor.ServerInterceptorPackage.ShutdownReason reason)
{
System.out.println("shutdown " + reason);
System.exit(0);
}
}
ExitServerInterceptorFactory.java
package exit;
import com.visigenic.vbroker.interceptor.*;
public class ExitServerInterceptorFactory implements ServerInterceptorFactory
{
private ExitServerInterceptor _inter = null;
public ServerInterceptor create(com.visigenic.vbroker.IOP.TaggedProfile profile)
{
if (_inter == null)
{
_inter = new ExitServerInterceptor();
}
return _inter;
}
}
Init .java
package exit;
import java.util.*;
import com.visigenic.vbroker.orb.*;
import com.visigenic.vbroker.interceptor.*;
public class Init extends com.visigenic.vbroker.orb.ServiceInit
{
public void init(org.omg.CORBA.ORB orb, Properties properties)
{
System.out.println("Installing Exit Interceptor");
try
{
ChainServerInterceptorFactory serverFactory =
ChainServerInterceptorFactoryHelper.narrow(
orb.resolve_initial_references("ChainServerInterceptorFactory"));
serverFactory.add(new ExitServerInterceptorFactory());
}
catch(org.omg.CORBA.ORBPackage.InvalidName e)
{
throw new org.omg.CORBA.INITIALIZE("Exit Interceptor not installed: " + e);
}
}
}
Article originally contributed by