Sample of GetFragment Activity Using Dynamic Input Source

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. In this sample, the GetFragment activity accepts a dynamic input source that is, a live stream as an input and splits the XML file into fragments depending on the Fragment Criteria. The file names used in this sample are specified in module property.

Before you begin

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 the name GetFragmentUsingDynamicInputstream.bwp and LivestreamWriterSimulator.bwp. In Module Descriptors > Components, you can see GetFragmentUsingDynamicInputstream.bwp and LivestreamWriterSimulator.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, a Livestream Writer Simulator and a GetFragment Using Dynamic Inputstream.

  • The Livestream Writer Simulator generates a live stream which is an input to GetFragment activity.
  • In GetFragment Using Dynamic Inputstream, the following options are set:
    • Input XML Source is selected as input stream
    • Dynamic Input Source check box is enabled
    • timeout is set to 1000msec
    • Output Source is set to output stream

The Fragment Criteria is set to no. of records. 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 using StreamToFile activity at a specified location.