Sample of GetFragment Activity Using TCP Stream

The GetFragment activity is designed to iterate through the XML fragments one by one. This activity is designed to run with Loop Group activity to allow iterating through all the XML fragments. The GetFragment activity accepts a TCP stream as an input and splits the XML file into fragments depending on the fragment criteria specified. The file names used in this sample are specified in module property.

Prerequisites

Before executing the project, set the module property LargeXML_Root to the location of the plug-in samples folder. For example, if the plug-in samples are available in $TIBCO_HOME/bw/palettes/lx/<version>/samples, set LargeXML_Root to $TIBCO_HOME/bw/palettes/lx/<version>/samples. The rest of the input and output paths are configured using this module property.

Procedure

  1. In the samples directory, select <TIBCO HOME> bw > palettes > lx > <version> > samples and double-click tibco.bw.sample.palette.bwlx.LargeXMLPluginSample.
  2. In Project Explorer, expand the tibco.bw.sample.palette.bwlx.LargeXMLPluginSample project.
  3. Set the default ApplicationProfile to match your operating system.
  4. Fully expand the Processes directory and double-click GetFragmentUsingTCPStream.bwp and TCPServerSimulator.bwp. In Module Descriptors > Components, you can see GetFragmentUsingTCPStream.bwp and TCPServerSimulator.bwp.
  5. Click Run > Debug Configurations.
  6. In the left tree of the Debug Configuration wizard, expand BusinessWorks Application and select BWApplication.
  7. Click the Applications tab and then click Deselect All if you have multiple applications. Select the check box next to tibco.bw.sample.palette.bwlx.LargeXMLPluginSample.application.
  8. Click Debug. This runs the sample in the Debug mode.
  9. Click the Terminate icon to stop the process.

Result

  • The number of split files created as per Fragment Criteria in $TIBCO_HOME/bw/palettes/lx/<version>/samples/LargeXML/data/output/.
  • End of file (EOF) must be true at the end of the iteration.

Understanding the Configuration

The following activities are used in this sample:

  • GetFragment: Splits the XML file in loop group activity according to Fragment Criteria.
  • StreamToFile: The activity writes a file to the disk from the output data stream.

There are two processes, TCP Server Simulator and GetFragment Using TCP Stream, for splitting elements.

  • The TCP Server Simulator process generates a TCP stream which is used as an input to the GetFragment activity for splitting it into chunks. The input and output paths are configured using global variables.
  • The GetFragment Using TCP Stream process, opens a TCP connection, selects input stream as the Input XML Source, and Output Source is set to output stream.

By default, Fragment Criteria is the size of the fragment. The Fragment Criteria Value is the value required for splitting the XML file according to Fragment Criteria. The elementName is the element used as split criteria. The files are written to the disk at specified location.