Try OpenEdge Now
skip to main content
Developing AppServer Applications
Programming ABL Client Applications : Connecting an application service or AppServer instance : Connection examples : Connecting to a session-free AppServer
 
Connecting to a session-free AppServer
In this session-free connection example, the connection-parameters argument to the CONNECT( ) method contains the -AppService, -H, -S, -sessionModel, and -initialConnections parameters, as shown:
DEFINE VARIABLE hInventory AS HANDLE NO-UNDO.
DEFINE VARIABLE lReturn    AS LOGICAL NO-UNDO.

CREATE SERVER hInventory.
lReturn = hInventory:CONNECT("-AppService inventory -S 5163 -H 4glservices
  -sessionModel Session-free -initialConnections 25").
IF NOT lReturn THEN DO:
  DELETE OBJECT hInventory NO-ERROR.
  RETURN ERROR "Failed to connect to Inventory application service".
END.
IF ERROR-STATUS:ERROR THEN DO:
  lReturn = hInventory:DISCONNECT().
  DELETE OBJECT hInventory NO-ERROR.
  RETURN ERROR RETURN-VALUE.
END.
. . .
lReturn = hInventory:DISCONNECT().
DELETE OBJECT hInventory NO-ERROR.
This code tries to connect the inventory application service by setting up an initial connection pool containing 25 physical connections to AppServers that support this application service. It sends its connection request to a NameServer that runs on a machine with the host name, 4glservices and is listening on UDP port 5163. When the CONNECT( ) method executes, the NameServer returns the location of an AppServer broker that supports the inventory application service, once for each of the 25 requested physical connections. The client then creates the 25 physical connections to these brokers, distributed randomly and according to load balance settings (if any) established for the application service.