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

  1. In the samples directory, select palette > tcp > SharedTCPConnection and double-click tibco.bw.sample.palette.tcp.SharedTCPConnection. For more information, see Accessing Samples.
  2. In the Project Explorer view, expand the tibco.bw.sample.palette.tcp.SharedTCPConnection project.
  3. Set the default ApplicationProfile to match the OS you are running on. For more information, see Setting the Default Application Profile.
  4. 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.
  5. Click Run > Debug Configurations.
  6. At the left hand tree of Debug Configuration wizard, expand BusinessWorks Application and select BWApplication.
  7. Click the Applications tab and then click the Deselect All button if you have multiple applications. Select the check box next to tibco.bw.sample.palette.tcp.SharedTCPConnection.application.
  8. Click Debug.
    This runs the sample in Debug mode.
  9. Click the Terminate icon to stop the process.

Result

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.