Skip to main content

Visibroker Connection and Request Timeout Properties and Policies

  • February 16, 2013
  • 0 replies
  • 2 views

Problem:

  • Product Name: VisiBroker
  • Product Version: 3.x, 4.x, 5.x, and 6.x
  • Product Component: Quality of Service (QoS), Timeout
  • Platform/OS Version: All

Visibroker Connection and Request Timeout Properties and Policies

Resolution:

Overview

The following table summarizes the connection level timeout options available for VBC and VBJ. The notes following the table describe the feature in detail and provide provide useful code samples.

Timeout

Release     connect      send          receive     
VBJ 3.x no yes (1) yes
VBJ 4.x yes (2) no no
VBJ 5.x yes yes yes
VBJ 6.x yes yes yes
VBC 3.x yes (3) yes yes
VBC 4.x yes (4) yes yes
VBC 5.x yes yes yes
VBC 6.x yes yes yes


Details

Each note in the table above is explained in the following paragraphs.

Note (1) For VBJ 3.4 the ORBtcpTimeout property will associate a timeout with all socket writes and reads. This property is an ORB level property, so there is no way to obtain object level or thread level granularity. Thus the option is only useful in pure clients where all CORBA requests are sent from the same thread. The default behavior of the stub is to catch the exception generated by the timeout and reinvoke the request. In order to allow the application to detect the timeout it is also necessary to associate a BindOptions structure with the enable_rebind member set to false.

Example:
 

java.util.Properties orbprops= new java.util.Properties();
 
orbprops.put("ORBtcpTimeout", "300000"); // 300 seconds
 
org.omg.CORBA.ORB orb= org.omg.CORBA.ORB.init(args, orbprops);
 
org.omg.CORBA.BindOptions bo = new org.omg.CORBA.BindOptions(false, false);
 
((com.inprise.vbroker.CORBA.ORB)orb).default_bind_options(bo);

The ORBtcpTimeout can also be supplied as an applet parameter, system property, or command line argument.

In some cases it will be necessary to associate the BindOptions directly with an object reference rather than setting the ORB level default.

For example:
 
 

Bank.AccountManager manager = ...

manager._bind_options(bo);


 
Note (2) For VBJ 4.x tthe Qos RelativeConnectionTimeoutPolicy can be used to establish a connection timeout at the ORB, thread, or object
level. Units for the timeouts are in 100 ns.
Example:

short rebindMode=TRANSPARENT.value;
 // or .. rebindMode=NO_RECONNECT.value;
 int timeout = 10 * 1000 * 10000; // 10 seconds
 org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args,null);
 byte[] managerId = "BankManager".getBytes();
 Bank.AccountManager manager = Bank.AccountManagerHelper.bind(orb, "/rebind_agent_poa", managerId);
 Any timeoutValue = orb.create_any();
 timeoutValue.insert_long(timeout);
 Policy timeout_policy = orb.create_policy(RELATIVE_CONN_TIMEOUT_POLICY_TYPE.value, timeoutValue);
 Any rebindValue= orb.create_any();
 RebindModeHelper.insert(rebindValue, rebindMode);
 Policy rebind_policy = orb.create_policy(REBIND_POLICY_TYPE.value, rebindValue);
 PolicyManager orbManager = PolicyManagerHelper.narrow(orb.resolve_initial_references("ORBPolicyManager"));
 
// Install the policy at the orb level.
 orbManager.set_policy_overrides(
 new Policy[] {rebind_policy, timeout_policy},SetOverrideType.SET_OVERRIDE);

Although the QoS policies for request timeouts are not available in VBJ 4.x, a custom patch is available which provides the property vbroker.orb.tcpTimeout. This property behaves as an ORB level relative request round trip timeout and is similar to the VBJ 3.x ORBtcpTimeout property. Premium support customers can download this patch from the download area for the VisiBroker 4.5.1 product.

Note (3) For VBC 3.3 the BindOptions structure can be provided as an object level default or associated with a specific object reference.

Example:

CORBA::BindOptions bindOptions;
 bindOptions.send_timeout = 300;
 bindOptions.receive_timeout = 300;
 bindOptions.connection_timeout = 300;
 bindOptions.defer_bind = 0;
 bindOptions.enable_rebind = 1;
 // Bind to an account.
 Account_var account = Account::_bind((const char *) "Test",
 NULL, &bindOptions, orb);
 A default BindOptions can be set as follows:
 // Set up default bind options
 CORBA::BindOptions_var bindOptions =
 CORBA::Object::_default_bind_options();
 bindOptions->connection_timeout = 300;
 bindOptions->send_timeout = 300;
 bindOptions->receive_timeout = 300;
 bindOptions->defer_bind = 0;
 bindOptions->enable_rebind = 1;
 CORBA::Object::_default_bind_options(*bindOptions);

 
Note that this example shows how to supply BindOptions at the time of the Visibroker bind call. This does not imply that BindOptions only apply to clients that use the Visibroker _bind() method tolocate objects. For objects that are obtained through other means, such as a stringified IOR or the naming service, BindOptions can be associated directly with the object reference. For example:

CORBA_Object_var cop = ...
 Account_var account = Account::_narrow(cop);
 CORBA::BindOptions bindOptions;
 bindOptions.defer_bind = 0;
 bindOptions.enable_rebind = 1;
 bindOptions.send_timeout = 300;
 bindOptions.receive_timeout = 300;
 bindOptions.connection_timeout = 300;
 account->_bind_options(bindOptions);

Note (4) For VBC 4.x, VBC 5.x, VBC 6.x , VBJ 5.x, andVBJ 6.x the QoS (QoSExt and Messaging) policies can be used to establish timouts. Units for the timeouts are in 100 ns.

timeout            equivalent policy (almost)
---------------      -------------------------------------------
connection      QoSExt::RelativeConnectionTimeoutPolicy
send                Messaging::RelativeRequestTimeoutPolicy
receive            Messaging::RelativeRoundtripTimeoutPolicy

Note that Messaging::RelativeRoundtripTimeoutPolicy can be used as a receive timeout, however there is subtle difference that distinguishes it from the receive timeout of the VBC 3.x BindOptions.

RelativeRoundtripTimeoutPolicy actually includes the time to send and receive the request, not just the time waiting to receive a reply. Hence the ORB runtime will subtract the RelativeRequestTimeoutPolicy value from the RelativeRoundtripTimeoutPolicy value to form the effective receive timeout.It is important to make sure that the RelativeRoundtripTimeoutPolicy is greater than the RelativeRequestTimeoutPolicy and that the effective receive timeout is really the difference between the two. This is indicated in the comments in the sample code below. If RelativeRequestTimeoutPolicy and RelativeRoundtripTimeoutPolicy are set to the same value, the effective receive timeout will be zero, indicating that the ORB will wait indefinitely for a reply.

C Example:

// Setup Qos policies
 // Messaging::RebindMode rebind_mode = Messaging::TRANSPARENT;
 // or... rebind_mode = Messaging::NO_RECONNECT;
 Messaging::RebindMode rebind_mode = QoSExt::VB_TRANSPARENT;
 CORBA::Any rebind_value;
 rebind_value <<= rebind_value;
CORBA::Policy_var rebind_policy =
 orb->create_policy(Messaging::REBIND_POLICY_TYPE,rebind_value);
 CORBA::Any con_timeout_value;
 CORBA::Any snd_timeout_value;
 CORBA::Any rt_timeout_value;
 // 1 second (TimeT has 100 nanosecond resolution).
 TimeBase::TimeT timeout = 10000000;
 // 5 seconds
 con_timeout_value <<= 5 * timeout;
 snd_timeout_value <<= 5 * timeout;
// 60 seconds
 // note: rt = snd   rcv so rt > snd. if rt = snd, then it
 // is effectively 0 and will not work.
 rt_timeout_value <<= 60 * timeout;
CORBA::Policy_var con_timeout_policy =
 orb->create_policy(QoSExt::RELATIVE_CONN_TIMEOUT_POLICY_TYPE, con_timeout_value);
 CORBA::Policy_var snd_timeout_policy =
 orb->create_policy(Messaging::RELATIVE_REQ_TIMEOUT_POLICY_TYPE, snd_timeout_value);
 CORBA::Policy_var rt_timeout_policy =
 orb->create_policy(Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE,rt_timeout_value);
 CORBA::PolicyList policies;
 policies.length(4);
 policies[0] = CORBA::Policy::_duplicate(rebind_policy);
 policies[1] = CORBA::Policy::_duplicate(con_timeout_policy);
 policies[2] = CORBA::Policy::_duplicate(snd_timeout_policy);
 policies[3] = CORBA::Policy::_duplicate(rt_timeout_policy);
 // Install the policies at the orb level.
 CORBA::Object_var obj =
 orb->resolve_initial_references("ORBPolicyManager");
 CORBA::PolicyManager_var orb_mgr =
 CORBA::PolicyManager::_narrow(obj);
 orb_mgr->set_policy_overrides(policies, CORBA::SET_OVERRIDE);
 // ... etc

Please refer to the following OMG document, paragraph 5.3.4 for further details.

  • ftp://ftp.omg.org/pub/docs/orbos/98-05-05.pdf

Also you may wish to review the Visibroker\\QoS_policies example to see examples of how these policies are created and associated with the ORB.

 

Related Article

[[knowledge_base: VBJ 5.2.1: Why do I get a deprecated warning for BindOptions?]]
 

#Security
#VisiBroker