[Ace-users] [tao-users] How to set different message timeout policies for different calls
Adam Mitz
mitza at ociweb.com
Wed Feb 13 13:41:24 CST 2008
Keith Nicewarner wrote:
>
> I’m using the message timeout policy like this:
>
> // Create the policy and put it in a policy list.
>
> CORBA::PolicyList policies;
>
> policies.length(1);
>
> policies[0] =
>
> orb->create_policy(::Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE,
>
> relative_rt_timeout_as_any);
>
> // Apply the policy at the ORB level using the ORBPolicyManager.
>
> CORBA::Object_var obj =
> orb->resolve_initial_references("ORBPolicyManager");
>
> CORBA::PolicyManager_var policy_manager =
>
> CORBA::PolicyManager::_narrow(obj.in());
>
> policy_manager->set_policy_overrides(policies,
>
> CORBA::SET_OVERRIDE);
>
> This sets the timeout for all client calls in my process (they all use
> the same ORB). But I want to set different timeouts for different
> calls on the same object. In fact, I might want to set the timeout
> dynamically (i.e. compute the timeout on the fly). Do I need to create
> a separate ORB for each timeout value or can I switch the policy on
> the fly? Or is there a better way to specify a per-method timeout value?
>
Set the policy at the object or thread level, whichever is appropriate
for your situation, instead of on the ORB. If you set the policy on the
object level you get a new object reference that enforces the policy, so
you can have as many of these as you'd like. See the
_set_policy_overrides() method of CORBA::Object. (This is discussed in
Section 7.3.1.2 of the TAO Developer's Guide.)
Thanks,
Adam Mitz
Software Engineer
Object Computing, Inc.
More information about the Ace-users
mailing list