diff --git a/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingMethodInvokerHelper.java b/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingMethodInvokerHelper.java index 60730cfd97..ac8b21a5ef 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingMethodInvokerHelper.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingMethodInvokerHelper.java @@ -537,7 +537,7 @@ public class MessagingMethodInvokerHelper extends AbstractExpressionEvaluator { Annotation match = null; for (Annotation annotation : annotations) { Class type = annotation.annotationType(); - if (type.equals(Payload.class) || type.equals(Header.class) || type.equals(Headers.class)) { + if (type.equals(Payload.class) || type.equals(Payloads.class) || type.equals(Header.class) || type.equals(Headers.class)) { if (match != null) { throw new MessagingException( "At most one parameter annotation can be provided for message mapping, " diff --git a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/MethodInvokingMessageGroupProcessorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/MethodInvokingMessageGroupProcessorTests.java index fcc02c3358..4e5a576233 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/aggregator/MethodInvokingMessageGroupProcessorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/aggregator/MethodInvokingMessageGroupProcessorTests.java @@ -188,6 +188,35 @@ public class MethodInvokingMessageGroupProcessorTests { assertThat((String) messageCaptor.getValue().getPayload(), is("[1, 2, 4, 3, 101, 102]")); } + @Test + @SuppressWarnings("unchecked") + public void shouldUseAnnotatedPayloads() throws Exception { + + @SuppressWarnings("unused") + class SimpleAggregator { + @Aggregator + public String and(@Payloads List flags) { + List result = new ArrayList(); + for (int flag : flags) { + result.add(flag); + } + return result.toString(); + } + public String or(List flags) { + throw new UnsupportedOperationException("Not expected"); + } + } + + MessageGroupProcessor processor = new MethodInvokingMessageGroupProcessor(new SimpleAggregator()); + ArgumentCaptor messageCaptor = ArgumentCaptor.forClass(Message.class); + when(outputChannel.send(isA(Message.class))).thenReturn(true); + when(messageGroupMock.getUnmarked()).thenReturn(messagesUpForProcessing); + processor.processAndSend(messageGroupMock, messagingTemplate, outputChannel); + // verify + verify(messagingTemplate).send(eq(outputChannel), messageCaptor.capture()); + assertThat((String) messageCaptor.getValue().getPayload(), is("[1, 2, 4]")); + } + @Test @SuppressWarnings("unchecked") public void shouldFindSimpleAggregatorMethodWithCollection() throws Exception {