Best Practices for EAServer clients including HA/Failover

The best practice is to have ConnectToServer() and CreateInstance() inside the same event (a button, for example). If failover occurs then the client reissues the same coding, which needs to pass through ConnectToServer() again to connect to the next EAServer in the cluster. In this case, the next EAServer in cluster would be found successfully.

Scenario in PB Client Application

Suppose ConnectToServer() is inside a window Open() event and CreateInstance() is inside a button in the same window. If failover occurs while window is active, and the end user clicks the button again, the CreateInstance() itself is not able to resolve the failover reconnection and PowerBuilder will fail with CORBA_COMM_FAILURE.

Example

This problem can be avoided by including both ConnectToServer() and CreateInstance() inside same event or method. For instance:

In the window Open() event, place the following:

connection.Driver     = "AppServer"
connection.UserID     = "admin@system"
connection.Password   = "repsyb1"
connection.Location   = &
   "iiop://10.36.17.135:2000;iiop://10.36.17.148:2000"
connection.options    = "ORBsocketReuseLimit = 10"

Then place the following in a button within the same window:

Long ll_result
ll_result = connection.Connecttoserver()
ll_result = connection.Createinstance(in_component, &
   "maison5/n_componente")
ll_result = in_component.f_test(50)
Messagebox("Result ",  ll_result)
gn_connect.DisconnectServer()

This ensures the failover to the next server works for EAServer client PowerBuilder application, if failover occurs when the end user presses the button again.