Java Reference
In-Depth Information
package com.apress.springenterpriserecipes.springintegration.solution014;
import org.apache.log4j.Logger;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.core.Message;
public class InboundHelloWorldFileMessageProcessor {
private static final Logger logger =
public void handleIncomingFileMessage(
Message<File> inboundJmsMessage) throws Throwable {
File filePayload = inboundJmsMessage.getPayload();
logger.debug(String.format("absolute path: %s, size: %s",
filePayload.getAbsolutePath(), filePayload.length()));
8-6. Transforming a Message from One Type to Another
You want to send a message into the bus and transform it before working with it further. Usually, this
is done to adapt the message to the requirements of a component downstream. You might also want
to transform a message by enriching it—adding extra headers or augmenting the payload so that
components downstream in the processing pipeline can benefit from it.
Use a transformer component to take a Message of a payload and send the Message out with a payload of
a different type. You can also use the transformer to add extra headers or update the values of headers
for the benefit of components downstream in the processing pipeline.
How it Works
Spring Integration provides a transformer message endpoint to permit the augmentation of the
message headers or the transformation of the message itself. In Spring Integration, components are
chained together, and output from one component is returned by way of the method invoked for that
component. The return value of the method is passed out on the “reply channel” for the component
to the next component, which receives it as an input parameter.
A transformer component lets you change the type of the object being returned or add extra headers
and that updated object is what is passed to the next component in the chain.
Search WWH ::

Custom Search