When using a remote CORBA object from a Java client, we make use of a
periodic heartbeat call to ensure the remote object is still
available.
If the process hosting the remote object dies, we get an exception
back immediately after making the call which helps us to know that we
need to re-connect.
If, however, the network goes down (i.e. unplug the machine running
the process hosting the remote object from the network), things get a
little tricker. At this point, you end up relying on the underlying
socket timeouts to control how soon you'll get back an exception.
We're using both C++/TAO/ACE clients and Java clients. For the C++
clients, we noticed that the timeout value varied significantly based
on operating system. For example, on Windows XP Home, it took 75
seconds to get an exception, but on Windows 2000 Pro, it only took 5
seconds.
The solution for the C++ clients was to make use of a policy override
in the ORB, specifying a 5 second timeout. This resulted in a uniform
timeout regardless of underlying operating system.
Now, we have to solve the same problem for the Java clients and I'm
wondering if there is a similar mechanism for Sun's built-in ORB. Any
ideas?
coder_1024 - 17 Mar 2004 05:09 GMT
> When using a remote CORBA object from a Java client, we make use of a
> periodic heartbeat call to ensure the remote object is still
[quoted text clipped - 22 lines]
> wondering if there is a similar mechanism for Sun's built-in ORB. Any
> ideas?
So far it looks like a way to do this is to use orb.create_policy().
Any examples for doing this with the default ORB packaged with Java?
coder_1024 - 18 Mar 2004 02:27 GMT
here's what I found out. The ORB provided by Sun doesn't appear to
provide a policy manager or any other way to specify object request
timeouts.
We've ended up using JacORB instead, which very easily plugs into the
JDK. With JacORB, we're able to specify an object request timeout
using the code below:
PolicyManager policyManager = PolicyManagerHelper.narrow(
orb.resolve_initial_references("ORBPolicyManager"));
Policy p = new org.jacorb.orb.policies.RelativeRoundtripTimeoutPolicy(objtimeout
* 10000000);
policyManager.set_policy_overrides(new Policy[]{ p },
SetOverrideType.ADD_OVERRIDE);
coder_1024 - 18 Mar 2004 10:50 GMT
> PolicyManager policyManager = PolicyManagerHelper.narrow(
> orb.resolve_initial_references("ORBPolicyManager"));
> Policy p = new org.jacorb.orb.policies.RelativeRoundtripTimeoutPolicy(objtimeout
> * 10000000);
> policyManager.set_policy_overrides(new Policy[]{ p },
> SetOverrideType.ADD_OVERRIDE);
Note that the objtimeout variable in the above is a long which
specifies the number of seconds for the timeout.