use of org.springframework.integration.annotation.Aggregator in project spring-integration by spring-projects.
the class TestAnnotatedEndpointWithDefaultAggregator method aggregatingMethod.
@Aggregator(inputChannel = "inputChannel")
public Message<?> aggregatingMethod(List<Message<?>> messages) {
List<Message<?>> sortableList = new ArrayList<>(messages);
Collections.sort(sortableList, new MessageSequenceComparator());
StringBuffer buffer = new StringBuffer();
Object correlationId = null;
for (Message<?> message : sortableList) {
buffer.append(message.getPayload().toString());
if (null == correlationId) {
correlationId = new IntegrationMessageHeaderAccessor(message).getCorrelationId();
}
}
Message<?> returnedMessage = new GenericMessage<>(buffer.toString());
this.aggregatedMessages.put(correlationId, returnedMessage);
return returnedMessage;
}
use of org.springframework.integration.annotation.Aggregator in project spring-integration by spring-projects.
the class TestAnnotatedEndpointWithReleaseStrategy method aggregatingMethod.
@Aggregator(inputChannel = "inputChannel")
public Message<?> aggregatingMethod(List<Message<?>> messages) {
List<Message<?>> sortableList = new ArrayList<>(messages);
Collections.sort(sortableList, new MessageSequenceComparator());
StringBuffer buffer = new StringBuffer();
Object correlationId = null;
for (Message<?> message : sortableList) {
buffer.append(message.getPayload().toString());
if (null == correlationId) {
correlationId = new IntegrationMessageHeaderAccessor(message).getCorrelationId();
}
}
Message<?> returnedMessage = new GenericMessage<>(buffer.toString());
this.aggregatedMessages.put(correlationId, returnedMessage);
return returnedMessage;
}
use of org.springframework.integration.annotation.Aggregator in project spring-integration by spring-projects.
the class TestAnnotatedEndpointWithCustomizedAggregator method aggregatingMethod.
@Aggregator(inputChannel = "inputChannel", outputChannel = "outputChannel", discardChannel = "discardChannel", sendPartialResultsOnExpiry = "true", sendTimeout = "98765432")
public Message<?> aggregatingMethod(List<Message<?>> messages) {
List<Message<?>> sortableList = new ArrayList<>(messages);
Collections.sort(sortableList, new MessageSequenceComparator());
StringBuffer buffer = new StringBuffer();
Object correlationId = null;
for (Message<?> message : sortableList) {
buffer.append(message.getPayload().toString());
if (null == correlationId) {
correlationId = new IntegrationMessageHeaderAccessor(message).getCorrelationId();
}
}
Message<?> returnedMessage = new GenericMessage<>(buffer.toString());
aggregatedMessages.put(correlationId, returnedMessage);
return returnedMessage;
}
use of org.springframework.integration.annotation.Aggregator in project spring-integration by spring-projects.
the class TestAggregatorBean method createSingleMessageFromGroup.
@Aggregator
public Message<?> createSingleMessageFromGroup(List<Message<?>> messages) {
List<Message<?>> sortableList = new ArrayList<>(messages);
Collections.sort(sortableList, new MessageSequenceComparator());
StringBuffer buffer = new StringBuffer();
Object correlationId = null;
for (Message<?> message : sortableList) {
buffer.append(message.getPayload().toString());
if (null == correlationId) {
correlationId = new IntegrationMessageHeaderAccessor(message).getCorrelationId();
}
}
Message<?> returnedMessage = new GenericMessage<>(buffer.toString());
if (correlationId != null) {
this.aggregatedMessages.put(correlationId, returnedMessage);
}
return returnedMessage;
}
Aggregations