INT-840 added docs for @MessageMapping annotation
This commit is contained in:
@@ -250,6 +250,38 @@ public class FooService {
|
||||
}
|
||||
|
||||
}</programlisting>
|
||||
<para>
|
||||
A more powerful and flexible way mapping Message parts to method arguments is to use <interfacename>@MessageMapping</interfacename>
|
||||
annotation which allows you to define expression via Spring 3.0 Expression Language support to help parse
|
||||
message parts and map them to method arguments.
|
||||
</para>
|
||||
<para>For example:</para>
|
||||
<para>
|
||||
<programlisting language="java">public void fromMessageToMethod(@MessageMapping(expression="headers.day")String argA,
|
||||
@MessageMapping(expression="#this")Message message,
|
||||
@MessageMapping(expression="payload")Employee payloadArg,
|
||||
@MessageMapping(expression="payload.fname")String value,
|
||||
@MessageMapping(expression="headers")Map headers){} </programlisting>
|
||||
|
||||
As you can see, the above method takes 5 arguments where:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>First - will be mapped to the value of 'day' header</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Second - will be mapped to the Message itself</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Third - will be mapped to the Payload</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Fourth - will be mapped to the 'fname' attribute of a Payload object</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Fifth - will be mapped to MessageHeaders</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<tip>
|
||||
A Map-typed argument does not strictly require the use of the @Headers annotation. In other words
|
||||
the following is also valid: <programlisting language="java">public void bar(String payload, Map<String, Object> headerMap)</programlisting>
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
The argument in the service method could be either a Message or an arbitrary type. If the latter, then it will
|
||||
be assumed that it is a Message payload, which will be extracted from the message and injected into such service
|
||||
method. This is generally the recommended approach as it follows and promotes a POJO model when working with Spring
|
||||
Integration. Arguments may also have @Header or @Headers annotations as described in <xref linkend="annotations"/>
|
||||
Integration. Arguments may also have @Header, @Headers or @MessageMapping annotations as described in <xref linkend="annotations"/>
|
||||
</para>
|
||||
<note>
|
||||
Since v1.0.3 of Spring Integration, the service method is not required to have an argument at all, which means you
|
||||
|
||||
Reference in New Issue
Block a user