diff --git a/spring-integration-reference/src/configuration.xml b/spring-integration-reference/src/configuration.xml index ed77ea98bd..5683fa19aa 100644 --- a/spring-integration-reference/src/configuration.xml +++ b/spring-integration-reference/src/configuration.xml @@ -250,6 +250,38 @@ public class FooService { } } + +A more powerful and flexible way mapping Message parts to method arguments is to use @MessageMapping +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. + +For example: + +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){} + +As you can see, the above method takes 5 arguments where: + + + First - will be mapped to the value of 'day' header + + + Second - will be mapped to the Message itself + + + Third - will be mapped to the Payload + + + Fourth - will be mapped to the 'fname' attribute of a Payload object + + + Fifth - will be mapped to MessageHeaders + + + A Map-typed argument does not strictly require the use of the @Headers annotation. In other words the following is also valid: public void bar(String payload, Map<String, Object> headerMap) diff --git a/spring-integration-reference/src/service-activator.xml b/spring-integration-reference/src/service-activator.xml index 79d53f1195..897c44bde3 100644 --- a/spring-integration-reference/src/service-activator.xml +++ b/spring-integration-reference/src/service-activator.xml @@ -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 + Integration. Arguments may also have @Header, @Headers or @MessageMapping annotations as described in Since v1.0.3 of Spring Integration, the service method is not required to have an argument at all, which means you