This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Sample 659: Huge EDI Message Processing with Smooks Mediator

Note that WSO2 EI is shipped with the following changes to what is mentioned in this documentation:

  • <PRODUCT_HOME>/repository/samples/ directory that includes all Integration profile samples is changed to <EI_HOME>/samples/service-bus/.
  • <PRODUCT_HOME>/repository/samples/resources/ directory that includes all artifacts related to the Integration profile samples is changed to <EI_HOME>/samples/service-bus/resources/.

Introduction

This sample demonstrates how to process huge EDI messages via the splitting and routing approach using the Smooks mediator. In this sample, the ESB reads a huge EDI input file through the VFS transport, then the Smooks mediator splits the message into parts and routes each split fragment to a specified location.

Prerequisites

  • Enable the VFS transport. For details, see Enable VFS.
  • Add the following configuration to the messageBuilders section of the <ESB_HOME>/repository/conf/axis2/axis2.xml file:

    <messageBuilder contentType="text/plain" class="org.apache.axis2.format.PlainTextBuilder"/>
  • Open the <ESB_HOME>/repository/sample/synapse_sample_659.xml file in a text editor and change the following VFS transport configuration parameters based on the directory locations applicable to you.
    • transport.vfs.FileURI- The input file location.
    • transport.vfs.MoveAfterProcess -  The location to move the input file after it is processed.
    • transport.vfs.MoveAfterFailure -  The location to move the input file if there happens to be a failure at the time of processing.
  • Open the <ESB_HOME>/repository/samples/resources/smooks/smooks-config-659.xml file in a text editor and replace /home/user/smooks/orders in the <file:destinationDirectoryPattern>/home/user/smooks/orders</file:destinationDirectoryPattern> configuration line to a directory location applicable to you.
  • For a list of general prerequisites, see Setting Up the ESB Samples.

Building the sample

The XML configuration for this sample is as follows: 

<definitions xmlns="http://ws.apache.org/ns/synapse">
	<localEntry key="smooks-key" src="file:repository/samples/resources/smooks/smooks-config-659.xml" />
	<proxy name="SmooksSample" transports="vfs" startOnLoad="true" trace="disable">
		<!--CHANGE-->
		<parameter name="transport.vfs.FileURI">file:///home/user/smooks/in</parameter>
		<parameter name="transport.vfs.ContentType">text/plain</parameter>
		<parameter name="transport.vfs.FileNamePattern">.*.txt</parameter>
		<parameter name="transport.PollInterval">5</parameter>
		<!--CHANGE-->
		<parameter name="transport.vfs.MoveAfterProcess">file:///home/user/smooks/original</parameter>
		<!--CHANGE-->
		<parameter name="transport.vfs.MoveAfterFailure">file:///home/user/smooks/fail</parameter>
		<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
		<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
		<target>
	    		<inSequence>
			   <smooks config-key="smooks-key">
			   	<input type="text" />
				<output type="xml" />
			   </smooks>
			</inSequence>
		</target>
	</proxy>
</definitions>

This configuration file synapse_sample_659.xml is available in the <ESB_HOME>/repository/samples directory.

To build the sample

  • Start the ESB with the sample 659 configuration. For instructions on starting a sample ESB configuration, see Starting the ESB with a sample configuration.

    The operation log keeps running until the server starts, which usually takes several seconds. Wait until the server has fully booted up and displays a message similar to "WSO2 Carbon started in n seconds."

Executing the sample

To execute the sample

Move the input-message-659.txt file from the <ESB_HOME>/repository/samples/resources/smooks directory to the location specified as transport.vfs.FileURI in the configuration.

If you want to try this sample with an input file of your own, be sure that the input file is in a format similar to input-message-659.txt.

Analyzing the output

You will see the output of the incoming message that is split and routed via the Smooks mediator in the destinationDirectoryPattern location you specified when following the prerequisites.