LibraryLink ToToggle FramesPrintFeedback

Transforming Message Content

FUSE Mediation Router supports a variety of approaches to transforming message content. In addition to a simple native API for modifying message content, FUSE Mediation Router supports integration with several different third-party libraries and transformation standards. The following kinds of transformations are discussed in this section:

The Java DSL has a built-in API that enables you to perform simple transformations on incoming and outgoing messages. For example, the rule shown in Example 2.3 appends the text, World!, to the end of the incoming message body.


Where the setBody() command replaces the content of the incoming message's body. You can use the following API classes to perform simple transformations of the message content in a router rule:

  • org.apache.camel.model.ProcessorType

  • org.apache.camel.builder.Builder

  • org.apache.camel.builder.ValueBuilder

The org.apache.camel.model.ProcessorType class defines the DSL commands you can insert directly into a router rule—for example, the setBody() command in Example 2.3. Table 2.2 shows the ProcessorType methods that are relevant to transforming message content:

Table 2.2. Transformation Methods from the ProcessorType Class

MethodDescription
Type convertBodyTo(Class type) Converts the IN message body to the specified type.
Type convertFaultBodyTo(Class type) Converts the FAULT message body to the specified type.
Type convertOutBodyTo(Class type) Converts the OUT message body to the specified type.
Type removeFaultHeader(String name) Adds a processor which removes the header on the FAULT message.
Type removeHeader(String name) Adds a processor which removes the header on the IN message.
Type removeOutHeader(String name) Adds a processor which removes the header on the OUT message.
Type removeProperty(String name) Adds a processor which removes the exchange property.
ExpressionClause<ProcessorType<Type>> setBody() Adds a processor which sets the body on the IN message.
Type setFaultBody(Expression expression) Adds a processor which sets the body on the FAULT message.
Type setFaultHeader(String name, Expression expression) Adds a processor which sets the header on the FAULT message.
ExpressionClause<ProcessorType<Type>> setHeader(String name) Adds a processor which sets the header on the IN message.
Type setHeader(String name, Expression expression) Adds a processor which sets the header on the IN message.
ExpressionClause<ProcessorType<Type>> setOutBody() Adds a processor which sets the body on the OUT message.
Type setOutBody(Expression expression) Adds a processor which sets the body on the OUT message.
ExpressionClause<ProcessorType<Type>> setOutHeader(String name) Adds a processor which sets the header on the OUT message.
Type setOutHeader(String name, Expression expression) Adds a processor which sets the header on the OUT message.
ExpressionClause<ProcessorType<Type>> setProperty(String name) Adds a processor which sets the exchange property.
Type setProperty(String name, Expression expression) Adds a processor which sets the exchange property.

The org.apache.camel.builder.Builder class provides access to message content in contexts where expressions or predicates are expected. In other words, Builder methods are typically invoked in the arguments of DSL commands—for example, the body() command in Example 2.3. Table 2.3 summarizes the static methods available in the Builder class.


The org.apache.camel.builder.ValueBuilder class enables you to modify values returned by the Builder methods. In other words, the methods in ValueBuilder provide a simple way of modifying message content. Table 2.4 summarizes the methods available in the ValueBuilder class. That is, the table shows only the methods that are used to modify the value they are invoked on (for full details, see the API Reference documentation).


You can convert between low-level and high-level message formats using the following commands:

FUSE Mediation Router supports marshalling and unmarshalling of the following data formats:

Artix Data Services is a powerful tool for converting documents and messages between different data formats. In Artix Data Services, you can use a graphical tool to define complex mapping rules (including processing of data content) and then generate stub code to implement the mapping rules. See Progress Artix Data Services home page and the Artix Data Services documentation for more details. The marshal() and unmarshal() DSL commands are capable of consuming Artix Data Services stub code to perform transformations on message formats. Example 2.4 shows a rule that unmarshals XML documents into a canonical format (Java objects) and then marshals the canonical format into the tag/value pair format.


[Note]Note

Artix Data Services is licensed separately from FUSE Mediation Router.