带有 JacORB 客户端超时策略的“org.omg.CORBA.BAD_OPERATION:无法提取 ulonglong”
Posted
技术标签:
【中文标题】带有 JacORB 客户端超时策略的“org.omg.CORBA.BAD_OPERATION:无法提取 ulonglong”【英文标题】:"org.omg.CORBA.BAD_OPERATION: Cannot extract ulonglong" with JacORB client timeout policy 【发布时间】:2014-10-20 11:18:25 【问题描述】:我正在尝试使用 JacORB 和 java 为 CORBA 连接实现客户端超时策略。 以下是我尝试实现的第一种方法
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();
这个实现抛出
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)
但是当我将 RELATIVE_RT_TIMEOUT_POLICY_TYPE 更改为 REPLY_END_TIME_POLICY_TYPE 时,它会正常运行,但由于客户端等待而没有超时,因此没有产生预期的结果。
我也尝试了以下方法,它运行时没有异常,但客户端再次无限期等待而没有超时。
Policy retquestTimeoutPolicy = new org.jacorb.orb.policies.RelativeRoundtripTimeoutPolicy (1000 * 10000);
applicationDataAccess._set_policy_override(new Policy[]retquestTimeoutPolicy, SetOverrideType.ADD_OVERRIDE);
我可能在这里遗漏了一些小东西,但我是 corba 流的新手。所以任何帮助都会很棒。
【问题讨论】:
【参考方案1】:要设置此策略,您应该使用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);
OpenORB 源代码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
【讨论】:
【参考方案2】:当您设置覆盖时,它会应用于新对象,例如
new_object_with_policy = applicationDataAccess._set_policy_override(....
尝试这样做?
【讨论】:
以上是关于带有 JacORB 客户端超时策略的“org.omg.CORBA.BAD_OPERATION:无法提取 ulonglong”的主要内容,如果未能解决你的问题,请参考以下文章