Talend ESB Policies - 6.3

Talend ESB Service Developer Guide

EnrichVersion
6.3
EnrichProdName
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
task
Design and Development
Installation and Upgrade
EnrichPlatform
Talend ESB

Talend offers custom policies that can be used within the Talend ESB, for example: the Correlation ID policy, the WSDL Schema Validation policy, the Custom Schema Validation policy, the Transformation policy, and the Compression policy.

However, those policies are only available in the Talend Enterprise and Talend Platform products. They can be find under the add-ons\registry\policies directory of the Talend ESB delivery, and can be uploaded to the Service Registry via the Talend Administration Center Web User Interface (for more information, see the Talend Administration Center User Guide), or via Service Registry commands (for more information, see the Talend ESB Infrastructure Services Configuration Guide).

Those policies can also be enabled by declaring the corresponding feature. For more information on how to enable some of them via feature, see the following sections.

Correlation ID Policy

The correlation ID feature provides support for setting a business correlation ID. A correlation ID can be set using:

Maven project dependency

To use the Correlation ID policy in your project, you have to implement the following dependency:

<dependency>
   <groupId>org.talend.esb.policies</groupId>
   <artifactId>correlationid-policy</artifactId>
</dependency>

Custom callback handler

The custom callback handler can be enabled via feature (supports both Soap and REST service):

<jaxrs:features>
    <bean class="org.talend.esb.policy.correlation.feature.CorrelationIDFeature"/>
</jaxrs:features>

<jaxws:properties>
  <entry key="correlation-id.callback-handler">
    <bean class="com.example.CorrelationHandler"/>
  </entry>
</jaxws:properties>

The bean class com.example.CorrelationHandler is a custom class which implements the org.talend.esb.policy.correlation.CorrelationIDCallbackHandler interface. If such callback class is not specified in the properties, then the correlation Id will be generated automatically by a default callback handler which provides a system UID. For more information, see Automated correlation ID generation (system UID).

It is also necessary to specify the correlation id handler:

<jaxws:properties>
  <entry key="correlation-id.callback-handler">
    <bean class="com.example.CorrelationHandler"/>
  </entry>
</jaxws:properties>

Automated correlation ID generation (system UID)

If you do not specify a callback handler and set type="callback" (or entirely omit the type attribute), then the id will be generated automatically as system UID, and the value will be the same for request and response:

Enabling via feature:

<jaxrs:features>
    <bean class="org.talend.esb.policy.correlation.feature.CorrelationIDFeature"/>
</jaxrs:features>

Transformation Policy

The Transformation policy allows to apply XSLT transformation to message payloads. The implementation is based on CXF interceptors.

Transformation configuration via Spring

To add the transformation feature to the endpoint, the transformation feature could be used:

Spring configuration

<bean id="xsltFeature" class="org.talend.esb.policy.transformation.feature.TransformationFeature">
    <property name="path" value="etc/requestTransformation.xsl"/>
    <property name="appliesTo" value="provider"/>
    <property name="message" value="request"/>
    <property name="type" value="xslt"/>
</bean>
<jaxws:client id="libraryHttp" serviceName="library:LibraryProvider"
      endpointName="library:LibraryHttpPort"
      address="http://localhost:8080/tesb-library-tutorial/services/LibraryHttpPort"
      serviceClass="org.talend.services.demos.library._1_0.Library">
    <jaxws:features>
        <ref bean="xsltFeature"/>
    </jaxws:features>
</jaxws:client>

Dependencies

When running a participant in servlet-container or as a standalone application, the following dependency should be used in the participant's pom.xml file:

pom.xml for servlet-based or standalone participants

<dependency>
    <groupId>org.talend.esb.policies</groupId>
    <artifactId>transformation-policy</artifactId>
    <version>${project.version}</version>
</dependency>

When running a participant in the Talend Runtime container, in the Require-Bundle section of Felix bundle plugin, the transformation-policy bundle should be mentioned:

OSGi environment pom.xml

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <configuration>
        <instructions>
            <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
            <Require-Bundle>
                ...
                transformation-policy
            </Require-Bundle>
        </instructions>
    </configuration>
    <extensions>true</extensions>
</plugin>

Compression policy

This section shows you how to use the Compression Feature in Talend ESB.

The compression feature of Talend ESB inherits the CXF GZIPOutInterceptor and enables GZIP compression of on-the-wire data. However, note that using Talend ESB Compression and CXF GZIP Compression together is not recommended.

The Talend ESB Compression feature is driven completely by the threshold attribute. So, the supported attribute is threshold - the value, in bytes, under which messages are not compressed. And its default value is "1024".

The Compression policy can be enabled via policy or by adding the feature, depending on the type of service (SOAP or REST).

Enabling via feature (support both Soap and REST service)

You can add the Compression feature to the features list:

<jaxws:features>
    <bean id="compressionFeature" class="org.talend.esb.policy.compression.feature.CompressionFeature">
        <property name="threshold" value="100"/>
    </bean>
</jaxws:features>