14.2 The <chain> Element

The <chain> element provides an 'input-channel' attribute, and if the last element in the chain is capable of producing reply messages (optional), it also supports an 'output-channel' attribute. The sub-elements are then filters, transformers, splitters, and service-activators. The last element may also be a router.

 <chain input-channel="input" output-channel="output">
     <filter ref="someSelector" throw-exception-on-rejection="true"/>
     <header-enricher error-channel="customErrorChannel">
         <header name="foo" value="bar"/>
     </header-enricher>
     <service-activator ref="someService" method="someMethod"/>
 </chain>

The <header-enricher> element used in the above example will set a message header with name "foo" and value "bar" on the message. A header enricher is a specialization of Transformer that touches only header values. You could obtain the same result by implementing a MessageHandler that did the header modifications and wiring that as a bean.