[英]“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. 我正在尝试使用带有Java的JacORB为CORBA连接实现客户端超时策略。 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. 但是,当我将RELATIVE_RT_TIMEOUT_POLICY_TYPE更改为REPLY_END_TIME_POLICY_TYPE时,它会毫无例外地运行,但由于客户端等待超时而没有产生预期的结果。
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. 我可能在这里错过了一些小东西,但是我对corba flow不熟悉。 so any help will be great. 所以任何帮助都会很棒。
To set this policy, you should use set_policy_overrides
method of the PolicyManager
object: 要设置此策略,应使用PolicyManager
对象的set_policy_overrides
方法:
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 OpenORB源中有一个示例https ://sourceforge.net/projects/openorb/files/OpenORB/1.4.0/OpenORB-1.4.0-src.zip/download:\\ OpenORB \\ src \\ examples \\ org \\ openorb \\ ORB \\例子\\消息\\ Client.java
When you set an override it applies to the new object eg 设置替代时,它将应用于新对象,例如
new_object_with_policy = applicationDataAccess._set_policy_override(.... new_object_with_policy = applicationDataAccess._set_policy_override(....
Try doing that ? 尝试这样做?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.