This documentation is for WSO2 Enterprise Integrator version 6.4.0 . View documentation for the latest release in the 6.x.x family and the latest release in the 7.x.x family.

All docs This doc
Skip to end of metadata
Go to start of metadata

The Smooks Mediator can be used to apply lightweight transformations on messages in an efficient manner. Smooks is a powerful framework for processing, manipulating and transforming XML. More information about Smooks can be obtained from the official Smooks website.


<smooks [config-key="string"]>
   <input [type="|text|xml"]/>
   <output [type="|text|xml|java"] [property="string"] [action="string"]/>


The parameters available for configuring the Smooks mediator are as follows:

Parameter NameDescription
Config-KeyThe key to access the Smooks configuration. The Smooks configuration should be saved in the Registry as a local entry before it can be used here. Click either Configuration Registry or Governance Registry to select the Smooks configuration from the resource tree.
InputYou can select either XML or Text as the input.
ExpressionThis parameter is used to enter an XPath expression to select the exact message block to which the transformation should be applied. If no expression is entered, the transformation would apply to the entire message body by default.

The format of the output. The output type can be XML, Text or Java, and the output can be one of the following.

  • Property: If this is selected, the output defined as a property will be saved in the message context for future use.
  • Expression: If this is selected, the output is defined as an expression and the following additional actions can be performed.
      • Add:The selected node will be added as a child to the message.
      • Replace: Selected node will be replaced in the message.
      • Sibling: Selected node will be added as a sibling.


Example 1: Performance tuning

Smooks can be used to split a file and send split results to a JMS endpoint. In this case, having a value other than -1 for jms:highWaterMark in the Smooks configuration file can result in a low throughput for message publishing, since Smooks will spend resources on message counting while the messages are being published. Therefore, it is recommended to use -1 as the highWaterMark value for high throughput values. The following is a sample Smooks configuration file with this setting. For more information on creating the Smooks configuration file, see the documentation in the official Smooks website.

Sample Smooks configuration
<?xml version="1.0" encoding="UTF-8"?>
 <smooks-resource-list xmlns="" xmlns:core="" xmlns:ftl="" xmlns:jms="">
   Filter the message using the SAX Filter (i.e. not DOM, so no
   intermediate DOM, so we can process huge messages...
   <core:filterSettings type="SAX" />
   <!-- Capture the message data 2 seperate DOM model, for "order" and "order-item" fragments... -->
   <resource-config selector="order,order-item">
   <!-- At each "order-iteam", apply a template to the "order" and "order-item" DOM model... -->
   <ftl:freemarker applyOnElement="order-item">
     Note in the template that we need to use the special FreeMarker variable ".vars"
     because of the hyphenated variable names ("order-item"). See
       <!-- Bind the templating result into the bean context, from where
       it can be accessed by the JMSRouter (configured above). -->
       <ftl:bindTo id="orderItem_xml" />
   <!-- At each "order-item", route the "orderItem_xml" to the ActiveMQ JMS Queue... -->
   <jms:router routeOnElement="order-item" beanId="orderItem_xml" destination="smooks.exampleQueue">
       <!-- Need to use special FreeMarker variable ".vars" -->
       <jms:correlationIdPattern>${[email protected]}-${.vars["order-item"][email protected]}</jms:correlationIdPattern>
     <jms:jndi properties="/repository/conf/" />
     <jms:highWaterMark mark="-1" />

Example 2: Referring files from the Smooks configuration

The following Smooks configuration refers a bindings file named mapping.xml. This file should be saved in <EI_HOME>/TESTDev directory in order to be accessed via the class path. These bindings will be applied during mediation when the Smooks configuration is included in a Smooks mediator configuration via the Registry.

<smooks-resource-list xmlns=""> 
    <resource-config selector="org.xml.sax.driver"> 
        <param name="mapping-model">TESTDev/smooks/mapping.xml</param> 


Sample 654: Smooks Mediator.

  • No labels