Runtime tools : Channels components : Java Client/Server Messaging APIs : Concepts : Permanent and dynamic connections
  
Permanent and dynamic connections
UNICOM® Digital Transformation Toolkit (UDTT™) provides the following ways to implement server-to-client event notification:
Permanent connections
Dynamic connections
When the toolkit connects a client interested in receiving events to the server using a permanent connection, it creates a dedicated URL connection for that client. The server runs a servlet in a thread to handle the connection. The thread runs in the server for as long as the client application runs. Permanent connections are the default type of connection for server-to-client event notification.
Dynamic connections provide a way to reduce resource consumption when you have a centralized server with many clients. In this situation, you have many threads running on the server, with the required URL connection servlet for each client receiving events from the server. All of the threads running for each connected client consumes the server's resources. A dynamic connection uses a socket on the server side when the server needs to send an event to the client. Once the client receives the event, the server closes the socket. The server does not need to maintain an open connection to the client, which saves resources.
To establish a dynamic connection, the client must pass its IP address, the permanentConnectionForEvents attribute, and port to the server. The client obtains its IP address using the Java API and the permanentConnectionForEvents and port number from the CSClient definition. Note that if there is more than one CSClient instance running on the client machine, the toolkit uses the settings for the instance that has the usedForServerToClientEventNotification setting set to true. This is because the server sends events to the client using the workstationID and the toolkit assumes that the client uses only one port to listen for events.
The server stores the connection type in the permanentConnectionForEvents attribute of the CSServer instance and the IP address and port in the session table. When the server needs to send an event to a client terminal ID, it looks up the corresponding IP address and port number in the session table. The server uses this information to open a socket. The server sends the event through the socket and then closes the socket. On the client side, the toolkit generates a CSNotificationEvent containing the event data, which the Event Manager then handles normally.
Go up to
Concepts