This documentation is for WSO2 Enterprise Service Bus version 4.7.0 . View documentation for the latest release.
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.

The Smooks Mediator requires the transformation definition to be passed in as an external resource. This transformation can be specified as a local entry or be stored in the registry. The mediator UI enables you to point the mediator to an existing local entry or a registry resource.


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

UI configuration

  • Config-Key
  • Input - User can define an input as:
    • Text
    • XML
    • Expression - Specify an xPath as an expression to pick the exact message block. Else, the entire 'message body' will be selected by default.
  • Output - Similar to input, the user can define how the output should be. When the user defines an output expression, there are additional operations that 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.


When the user defines an Output as a Property, the property will be saved in the messagecontext for future uses.

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. Following is a sample Smooks configuration file with this setting. For more information on creating the Smooks configuration file, see the documentation on 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:jndi properties="/repository/conf/" />
     <jms:highWaterMark mark="-1" />
  • No labels