...
Code Block |
---|
language | xml |
---|
title | Sample Smooks configuration |
---|
|
<?xml version="1.0" encoding="UTF-8"?>
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd" xmlns:core="http://www.milyn.org/xsd/smooks/smooks-core-1.3.xsd" xmlns:ftl="http://www.milyn.org/xsd/smooks/freemarker-1.1.xsd" xmlns:jms="http://www.milyn.org/xsd/smooks/jms-routing-1.2.xsd">
<!--
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">
<resource>org.milyn.delivery.DomModelCreator</resource>
</resource-config>
<!-- 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 http://freemarker.org/docs/ref_specvar.html.
-->
<ftl:template>/repository/resources/orderitem-split.ftl.txt</ftl:template>
<ftl:use>
<!-- Bind the templating result into the bean context, from where
it can be accessed by the JMSRouter (configured above). -->
<ftl:bindTo id="orderItem_xml" />
</ftl:use>
</ftl:freemarker>
<!-- At each "order-item", route the "orderItem_xml" to the ActiveMQ JMS Queue... -->
<jms:router routeOnElement="order-item" beanId="orderItem_xml" destination="smooks.exampleQueue">
<jms:message>
<!-- Need to use special FreeMarker variable ".vars" -->
<jms:correlationIdPattern>${order.@id}-${.vars["order-item"].@id}</jms:correlationIdPattern>
</jms:message>
<jms:jndi properties="/repository/conf/jndi.properties" />
<jms:highWaterMark mark="-1" />
</jms:router>
</smooks-resource-list>
|
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Ā <ESB_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.
Code Block |
---|
|
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd">
<resource-config selector="org.xml.sax.driver">
<resource>org.milyn.smooks.edi.EDIReader</resource>
<param name="mapping-model">TESTDev/smooks/mapping.xml</param>
</resource-config>
</smooks-resource-list> |
Samples
Sample 654: Smooks Mediator.