Search in sources :

Example 1 with Headers

use of org.springframework.messaging.handler.annotation.Headers in project spring-integration by spring-projects.

the class MethodInvokingMessageGroupProcessorTests method testHeadersParameters.

@Test
public void testHeadersParameters() throws Exception {
    class SingleAnnotationTestBean {

        @Aggregator
        public String method1(List<String> input, @Headers Map<String, ?> map) {
            return input.get(0) + map.get("foo");
        }
    }
    SingleAnnotationTestBean bean = new SingleAnnotationTestBean();
    MethodInvokingMessageGroupProcessor aggregator = new MethodInvokingMessageGroupProcessor(bean);
    SimpleMessageGroup group = new SimpleMessageGroup("FOO");
    group.add(MessageBuilder.withPayload("foo").setHeader("foo", "bar").build());
    group.add(MessageBuilder.withPayload("bar").setHeader("foo", "bar").build());
    assertEquals("foobar", aggregator.aggregatePayloads(group, aggregator.aggregateHeaders(group)));
}
Also used : Headers(org.springframework.messaging.handler.annotation.Headers) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) SimpleMessageGroup(org.springframework.integration.store.SimpleMessageGroup) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Test (org.junit.Test)1 SimpleMessageGroup (org.springframework.integration.store.SimpleMessageGroup)1 Headers (org.springframework.messaging.handler.annotation.Headers)1