Skip to main content

How to access 2 different naming services (for different purposes) in Client application without calling ORB_init() twice?

  • February 16, 2013
  • 0 replies
  • 0 views

Problem:

How to access 2 different naming services (for different purposes) in Client application without calling ORB_init() twice?

Resolution:

  • Product Name : BES VBE
  • Product Version : 6.5
  • Product Component : VisiNaming
  • Platform/OS version : All


This article provides some insight of accessing different Services in client application, in particularly the VisiNaming service.

There is a common mistake to call ORB_init() more than once to bootstrap the client with different IP addresses and port numbers of the multiple Naming services. This is not allowed as bootstrapping in Client can only be done once. ORB will ignore the 2nd (and subsequent) bootstrapping, though no errors will be thrown, and the Client can only access the first service that is bootstrapped.


A typical example of making Client application able to access 2 naming services will be as follows:

// Initialize the ORB
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
CORBA::Object_var rootContextObj1 = orb->string_to_object("corbaloc::localhost:3534/NameService");
CORBA::Object_var rootContextObj2 = orb->string_to_object("corbaloc::localhost:3536/NameService");
CosNaming::NamingContext_var rootContext1 = CosNaming::NamingContext::_narrow(rootContextObj1);
CosNaming::NamingContext_var rootContext2 = CosNaming::NamingContext::_narrow(rootContextObj2);

Note: that this piece of code is only relevant if you need to access 2 different naming services for different purposes. If you are using 2 naming services as a back-up to each other, you can use Master-slave configuration of the naming services. For further examination of this, please refer to the examples vbe/ins/naming_failover example to configure a master-slave naming service.

Old KB# 26348

#Security
#VisiBroker
#NamingService