Sharing a TCP Connection across Multiple Processes
A TCP connection can be shared across multiple processes or jobs. This simple sample shows the connection sharing across jobs. In a real-world scenario, the application implementation would handle the ordering or synchronization of request and responses when the connection is shared.
The process contains:
- Server: Receives multiple requests from the client processes and logs the request.
- Initialize Connection: Opens a TCP Connection to the server and sets the connection to a Shared variable.
- Client A/Client B/Client C: Client processes that use the shared connection to send requests.
- Procedure
- In the samples directory, select and double-click tibco.bw.sample.palette.tcp.SharedTCPConnection. For more information, see Accessing Samples.
- In the Project Explorer view, expand the tibco.bw.sample.palette.tcp.SharedTCPConnection project.
- Set the default ApplicationProfile to match the OS you are running on. For more information, see Setting the Default Application Profile.
- Fully expand the Processes directory. Two sub-packages are available, one containing the server and another containing three client processes and the initialize TCP connection process. Explore each process by double-clicking it.
- Click .
- At the left hand tree of Debug Configuration wizard, expand BusinessWorks Application and select BWApplication.
- Click the Applications tab and then click the Deselect All button if you have multiple applications. Select the checkbox next to tibco.bw.sample.palette.tcp.SharedTCPConnection.application.
- Click
Debug.
This runs the sample in Debug mode.
- Click the
Terminate
icon to stop the process.
The result, similar to the following, is written to the SharedTCPConnection.log file at C:\tmp\SharedTCPConnection.
Text 1 from Client A
Text 2 from Client B
Text 3 from Client C
Understanding the Configuration
The following properties are defined and the default values can be changed:
- The TCPConnectionProperty that points to the TCP shared resource connection.
- The FilenameProperty that points to the Output_File. This file is created by the sample process and contains the output. The default value is C:\tmp\SharedTCPConnection\SharedTCPConnection.log.