"org.omg.CORBA.BAD_OPERATION: Cannot extract ulonglong" with JacORB client timeout policy

I'm trying to implement a client timeout policy for a CORBA connection using JacORB with java. Following is the first method I tried to implement this

long timeout = 10000000L;
org.omg.CORBA.Any relativeRoundtripTimeoutValue = orb.create_any();
TimeTHelper.insert(relativeRoundtripTimeoutValue,timeout);
Policy[] policies = new Policy[1];
try {
    policies[0] = orb.create_policy(org.omg.Messaging.RELATIVE_RT_TIMEOUT_POLICY_TYPE.value,
                                        relativeRoundtripTimeoutValue);
    <client_stub>._set_policy_override(policies, SetOverrideType.ADD_OVERRIDE);
} catch (PolicyError e) {
    e.printStackTrace();
}

This implementation throws

Caused by: org.omg.CORBA.BAD_OPERATION: Cannot extract ulonglong  vmcid: 0x0  minor code: 0     completed: No
at org.jacorb.orb.Any.checkExtract(Any.java:118)
at org.jacorb.orb.Any.extract_ulonglong(Any.java:467)
at org.jacorb.orb.policies.RelativeRoundtripTimeoutPolicy.<init>(RelativeRoundtripTimeoutPolicy.java:58)
at org.jacorb.orb.ORB.create_policy(ORB.java:774)

But when I change RELATIVE_RT_TIMEOUT_POLICY_TYPE to REPLY_END_TIME_POLICY_TYPE this runs without an exception but did not yield the expected result as client waited without timing out.

I tried following approach also and it ran without an exception but again the client waited indefinitely without timing out.

Policy retquestTimeoutPolicy = new org.jacorb.orb.policies.RelativeRoundtripTimeoutPolicy (1000 * 10000);
applicationDataAccess._set_policy_override(new Policy[]{retquestTimeoutPolicy}, SetOverrideType.ADD_OVERRIDE);

I may be missing some small thing here but I'm new to corba flows. so any help will be great.

Upvotes: 0

Views: 446

Answers (2)

Dmitry
Dmitry

Reputation: 46

To set this policy, you should use set_policy_overrides method of the PolicyManager object:

  long timeout = 10000000L;
  PolicyManager opm = (PolicyManager) orb.resolve_initial_references("ORBPolicyManager");
  Any relativeRoundtripTimeoutValue = orb.create_any();
  TimeTHelper.insert(relativeRoundtripTimeoutValue, timeout);
  Policy[] policies = new Policy[1];
  policies[0] = orb.create_policy(RELATIVE_RT_TIMEOUT_POLICY_TYPE.value,
      relativeRoundtripTimeoutValue);
  opm.set_policy_overrides(policies, SetOverrideType.ADD_OVERRIDE);

There is an example in the OpenORB sources https://sourceforge.net/projects/openorb/files/OpenORB/1.4.0/OpenORB-1.4.0-src.zip/download: \OpenORB\src\examples\org\openorb\orb\examples\messaging\Client.java

Upvotes: 1

Nick Cross
Nick Cross

Reputation: 117

When you set an override it applies to the new object e.g.

new_object_with_policy = applicationDataAccess._set_policy_override(....

Try doing that ?

Upvotes: 0

Related Questions