INT-1107 POJO Aggregator can return a Message without that being wrapped in another Message.

This commit is contained in:
Mark Fisher
2010-04-28 22:21:53 +00:00
parent b8e5d36ca1
commit d27502650f
3 changed files with 114 additions and 1 deletions

View File

@@ -40,13 +40,17 @@ public abstract class AbstractAggregatingMessageGroupProcessor implements Messag
private final Log logger = LogFactory.getLog(this.getClass());
@SuppressWarnings("unchecked")
public final void processAndSend(MessageGroup group, MessageChannelTemplate channelTemplate,
MessageChannel outputChannel) {
Assert.notNull(group, "MessageGroup must not be null");
Assert.notNull(outputChannel, "'outputChannel' must not be null");
Object payload = this.aggregatePayloads(group);
Map<String, Object> headers = this.aggregateHeaders(group);
Message<?> message = MessageBuilder.withPayload(payload).copyHeadersIfAbsent(headers).build();
MessageBuilder<?> builder = (payload instanceof Message)
? MessageBuilder.fromMessage((Message<?>) payload)
: MessageBuilder.withPayload(payload);
Message<?> message = builder.copyHeadersIfAbsent(headers).build();
channelTemplate.send(message, outputChannel);
}