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:
1 |
connection.Driver     = "AppServer" |
1 |
connection.UserID     = "admin@system" |
1 |
connection.Password   = "repsyb1" |
1 |
connection.Location   = &<br>   "iiop://10.36.17.135:2000;iiop://10.36.17.148:2000" |
1 |
connection.options    = "ORBsocketReuseLimit = 10" |
Then place the following in a button within the same window:
1 |
Long ll_result |
1 |
ll_result = connection.Connecttoserver()<br>ll_result = connection.Createinstance(in_component, &<br>   "maison5/n_componente") |
1 |
ll_result = in_component.f_test(50) |
1 |
Messagebox("Result ", ll_result) |
1 |
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.